Promise.all combines an array of promises into one promise. If every input fulfills, the combined promise fulfills with their values in input order. If any input rejects, it rejects immediately with that reason. Use it when concurrent operations are all needed, such as fetching several sources before rendering a UI. section 8.1.3
Listing 8.4 Using Promise.all to combine multiple promises
const allPostsPromise = Promise.all( #A
[ #B
fetch("https://jsonplaceholder.typicode.com/posts/1"), #B
fetch("https://jsonplaceholder.typicode.com/posts/2"), #B
fetch("https://jsonplaceholder.typicode.com/posts/3"), #B
].map((fetchPromise) => #C
fetchPromise.then((response) => { #C
if (!response.ok) { #C
throw new Error(`Status code ${response.status}`); #C
} #C
return response.json(); #C
}), #C
), #C
);
allPostsPromise
.then((posts) => { #D
posts.forEach((post) => { #D
console.log(post); #D
}); #D
}) #D
.catch((reason) => { #E
console.error(`Request failed: ${reason}`); #E
}); #E
This example fetches three posts concurrently, checks each response, parses the JSON, and handles failure through catch. section 8.1.3
Choose a different combinator when the outcome you need differs:
- Promise.allSettled waits for every promise to settle and returns each outcome. section 8.1.3
- Promise.any fulfills with the first fulfilled promise; Promise.race settles with the first promise to settle. section 8.1.3


