From c53484e8a47dd05d38649e8fc4f28811deff8ebe Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Thu, 26 Aug 2021 08:03:39 +0000 Subject: [PATCH] API error Handling --- ranchimallflo_api.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index 3dda4ab..c91ca27 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -1139,16 +1139,13 @@ def updatePrices(): prices = {} # USD -> INR - response = requests.get( - f"https://api.exchangeratesapi.io/latest?base=USD&symbols=INR") + response = requests.get(f"https://api.exchangerate-api.com/v4/latest/usd") try: price = response.json() - if price['success'] == False: - raise ValueError('API response error') prices['USDINR'] = price['rates']['INR'] except ValueError: response = requests.get( - f"https://api.exchangerate-api.com/v4/latest/usd") + f"https://api.exchangeratesapi.io/latest?base=USD&symbols=INR") try: price = response.json() prices['USDINR'] = price['rates']['INR']