Reputation: 29867
I would like to execute multiple http requests in my Node.js app. I also want to wait until all of them have completed before proceeding to use the results. Is Javascript Promises the way this should be done or is there something more specific to Node that handles this better?
Upvotes: 0
Views: 1085
Reputation: 2572
Promise.all waits for all fulfillments (or the first rejection). You can go through below link for different ways to achieve this using Promise.allSettled().
Already been asked: Wait until all promises complete even if some rejected
or https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
Upvotes: 1
Reputation: 184
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise/all
Promises.all() seems to be what you are looking for
Upvotes: 0