SyntaxStudy
Sign Up
JavaScript Promise.all and Promise.allSettled
JavaScript Intermediate 4 min read

Promise.all and Promise.allSettled

Parallel Promises

Promise.all runs promises in parallel and resolves when all succeed (or rejects on first failure). Promise.allSettled waits for all regardless of outcome.

Example
const [user, posts, comments] = await Promise.all([
  fetch("/api/user").then(r => r.json()),
  fetch("/api/posts").then(r => r.json()),
  fetch("/api/comments").then(r => r.json()),
]);
// Never fails — inspect each result
const results = await Promise.allSettled([p1, p2, p3]);
results.forEach(({ status, value, reason }) => { /* ... */ });
Pro Tip

Promise.all fails fast — use Promise.allSettled when you need all results even if some fail.