Promise.all

A JavaScript function that starts waiting on several Promises at once and resolves when all of them have finished.

In more detail

If two requests each take 200 milliseconds, awaiting them one after the other takes 400, but Promise.all takes about 200. It resolves to an array of results in input order and rejects as soon as any one of them fails.

Examples

const [user, orders] = await Promise.all([getUser(id), getOrders(id)]);
The course uses it to remove server-side request waterfalls in Server Components.

Related terms

Taught in

References