Working with Multiple Promises: Gathering All Promises

Let's discuss the second approach, the all() method, to deal with the multiple promises.

“The all() static method of promise takes an array of promises and passes an array of resolved results to the then() function when all promises resolve.”

If any one of the given promises is rejected, the then() function is not called. The catch() function is used instead.

Service

We will soon use the all() function to work with multiple asynchronous tasks. However, before we get to the all() function, we need to create a small program that will execute calls concurrently. This will help you see the power of the all() method when ran asynchronously and concurrently.

Get hands-on with 1200+ tech skills courses.