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
- Promise — A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
- request waterfall — A chain of requests where each one only starts after the previous one finished, so their waiting times add up.
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
Taught in
- Async Data Fetching: Parallel Requests & Preloading — Next.js 15 & Modern App Router Architecture