In my REST API I have the following code
i = 0
for item in similar_items:
name= main.get_name_from_index(item [0])
url = main.get_url_from_index(item [0])
category = main.get_categories_from_index(item [0])
if (name!= None):
return {'Name': name, 'Category': category, 'URL': url }, 200 # return data and 200 OK code
i = i + 1
if i > 20:
break
This essentially intends to iterate through similar_items and to print out the top 20 however currently it only send the JSON object of the first one. I believe the problem is with the return statement but no matter where I place it I run into the same problem.
Would really appreciate if anyone can share how I can return the desired amount of objects instead of the first one.