I have on server an endpoint which returns millions of records which makes Angular app unresponsive, so I need to use paging on server side, and call the request several times synchronously.
To do that I need to send http request to get the pages one by one, so I need to send first request to GET page 1, second to GET page 2, .... etc until the server return empty response indicating that this was the last available page, then the loop should break.
How can this be done using angular http and observables?
CodePudding user response:
The RxJS expand
operator is a good fit for recursively calling a paginated API resource
This answer to a similar (but different) question would be a good example, although you may decide not to use the reduce
operator, which builds up a collection of the responses and emits them only when all have been received