Skip to content

Promise.all

In one line

Promise.all takes an iterable of promises and resolves with an array of results when all fulfill, or rejects on the first rejection.

In simple words

Promise.all runs multiple promises concurrently and waits for all of them to succeed. It returns a single promise that resolves with an array of results (in the same order as the input) once every input promise has fulfilled. If any promise rejects, Promise.all immediately rejects with that reason (short-circuiting).

The results array preserves the order of the input, regardless of which promise resolves first. This is perfect for fetching multiple independent resources in parallel: const [user, posts] = await Promise.all([fetchUser(), fetchPosts()]) runs both requests at once instead of sequentially.

If you want to tolerate some failures, use Promise.allSettled instead (it never rejects and gives each promise's status). Promise.all is the go-to combinator for "I need all of these to succeed".

Example

javascript
async function loadDashboard(userId) {
  const [user, posts, friends] = await Promise.all([
    fetch(`/api/users/${userId}`).then(r => r.json()),
    fetch(`/api/posts?user=${userId}`).then(r => r.json()),
    fetch(`/api/friends/${userId}`).then(r => r.json()),
  ]);
  return { user, posts, friends }; // all three ran in parallel
}

// If any fetch fails, the whole Promise.all rejects.

Three fetches run concurrently. Promise.all waits for all and returns results in order. Any rejection short-circuits.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary