Sunday 28 June 2020

Axios : How to run multiple requests one after the other?

I have a very large array of IDs (thousands of IDs). I want to loop through this array and for each value, make a request to an API like so :javascript [12, 32, 657, 1, 67, ...].forEach((id) => { axios.get(`myapi.com/user/${id}`).then(({ data }) => { console.log(data.name); }); });However, I have so many requests to make I can't make them asynchronous because my computer has limits... Is it possible to wait for each request to be finished before making the next one ?

Submitted June 28, 2020 at 11:25PM by to_fl

No comments:

Post a Comment