How to iterate over a set of results of unknown size through a callback function?

Sorry, if the headline is a little dumb, it's hard to condense into one sentence.

I use axios to request a result set from an HTTP endpoint. This endpoint can only transmit 50 records at a time, but will have an unknown total number of records. Usually I just do whilemy path, increasing the "startAt" parameter and breaking out of the loop when no more results are returned.

I can't do this here, though, since I can't breakget out of the loop while in the axios callback function (which I should use to determine if I have any results).

I feel this is a β€œdon't see forest for trees” problem, but can anyone suggest a better way out of this?

+4
source share

Source: https://habr.com/ru/post/1666231/


All Articles