BeginnerCoder

Lesson 19 — Promise.all

Wait for many at once

Promise.all([p1, p2, …]) starts from several Promises and gives one Promise that resolves to an array of all results. The results come back in the same order as you passed them, even if a later one finishes first. If any one fails, the whole thing fails.

const [a, b] = await Promise.all([fetchUser(), fetchPosts()]);

Why it matters: loading three things in parallel takes as long as the slowest one, not the sum of all three.

Want it another way?
Task

Wait for both delays together and print [ 1, 2 ] instead of two pending Promises.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with JavaScript Intermediate

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.