A
A
Alexander Litvinenko2016-09-16 08:25:07
JavaScript
Alexander Litvinenko, 2016-09-16 08:25:07

Pausing the loop before executing a query within an iteration?

In general, I got a little bad api, I make requests from the node with the request module.
The bottom line is, to get one data record, you need to make two requests.
1st request - I set the active id
2nd request - I get data by active id
And everything would be fine, but only the active id is tied to a single api key, you can only receive data by one id at a time.
At the input I have an array of id, it turns out you need to wait until both requests are completed, take the next id from the list and again two requests.
It never occurs to me how to solve it, at least beautifully.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-09-16
@alexey-m-ukolov

You need a chain of promises .
Load array sequentially

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question