My exercises 3 & 6 ran extremely long and I am not sure how to debug. Exercise 6 I can ran the scripts but the playlist_items_.json never got created and I can see in the terminal that request was constantly made.
My exercise 3 code was as follows. I have to manually stoped it otherwise it is an infinite loop. Can anyone shed some light on how to solve the infinite loop?(I have little experience working with APIs)
def paginated_with_next_featured_playlists(endpoint_request: Callable, url: str, access_token: str) → list:
“”"Manages pagination for API requests done with the endpoint_request callable
Args:
endpoint_request (Callable): Function that performs API request
url (str): Base URL for the request
access_token (str): Access token
Returns:
list: Responses stored in a list
"""
responses = []
next_page = url
kwargs = {
"url": url,
"access_token": access_token,
"next": ""
}
#ctn =0
while next_page :
### START CODE HERE ### (~ 4 lines of code)
# Call the endpoint_request() function with the arguments specified in the kwargs dictionary.
# CODE DELETED
# Use extend() method to add the playlist's items to the list of responses.
# CODE DELETED
# Reassign the value of next_page as the 'next' value from the response["playlists"] dictionary.
# CODE DELETED
# Update the kwargs dictionary: set the value of the key 'next' as the variable next_page.
# CODE DELETED
# ctn+=1
### END CODE HERE ###
print(f"Executed request with URL: {response.get('playlists').get('href')}.")
return responses