oezilot
New Coder
Hi everyone,
I'm running into a KeyError: 'data' when fetching data from the Jikan API in my Flask app. This used to work fine, and another program using the same API (also written by ChatGPT) is still functioning correctly, so the API itself should be working as expected.
Here is the relevant part of the code:
My Questions:
I'm running into a KeyError: 'data' when fetching data from the Jikan API in my Flask app. This used to work fine, and another program using the same API (also written by ChatGPT) is still functioning correctly, so the API itself should be working as expected.
Here is the relevant part of the code:
Python:
def fetchData():
# store params und page in a session
page = session.get('page', 1)
params = session.get('params', {})
# fetching the data with the api depending on the params and page
response = requests.get(urlBuilder(page, params))
# safe data in a variable
if response.status_code == 200:
data = response.json()
return data['data']
else:
return None
My Questions:
- Has anyone experienced the 'data' key missing from the Jikan API response, despite getting a 200 status code?
- Could this issue be related to Flask sessions? I’m using session.get() to store and retrieve the page and params, and I’m wondering if the session data could be getting lost or not persisting correctly between requests.
- Any ideas why this would suddenly stop working, even though the same API works fine in another program?