简体   繁体   中英

Waiting for multiple asynchronous http requests to complete

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM