What is an appropriate way to handle API loop with progress indicator?

163 views Asked by At

Server is currently returning 100 items in an array plus with additional pagination information like how many total pages are there. Request parameter is also accepting current page to return appropriate items.

I have to display a progress indicator based on current page progress and fetch.

For example: I have received 100 items with total pages = 4 by making api call with request parameter page = 1. Then I can make another looped api calls with current page = 2,3 and 4 but there would be a problem in progress indicator that it can't pre-assume the total pages without receiving 1st API response.

What would be the appropriate way to handle such loop api calls ?

I think we need another api call which will return total pages first and then i can handle my progress indicator in advance and keep on updating progress based on results.

0

There are 0 answers