Promise.all() is the JavaScript method you use when multiple promises can run in parallel and the next step should wait for all of them to finish. It is the standard pattern for grouped async work such as loading several resources at once.
The method resolves with an array of results in the same order as the input promises. If any promise rejects, the whole call rejects immediately. If you are comparing single-promise flows too, wait for async function to finish is the related article.
Tested on: Node.js v20.18.2. A short note after each runnable snippet describes what you should see in the console.
Method 1: Wait for parallel promises
Promise.all() waits for every promise in the list to resolve.
Promise.all([Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)])
.then((values) => console.log("promise-all:", values.join(",")));You should see one line logging promise-all: 1,2,3.
Use this when the next step depends on all values being ready together.
Method 2: Handle rejections from Promise.all()
If one promise rejects, the combined promise rejects immediately.
Promise.all([Promise.resolve(1), Promise.reject(new Error("boom"))])
.catch((error) => console.log("promise-all-error:", error.message));You should see one line logging promise-all-error: boom.
This behavior matters when you need all results or no result at all.
Method 3: Use Promise.all() with async/await
await keeps the grouped promise flow readable.
async function run() {
const values = await Promise.all([Promise.resolve("A"), Promise.resolve("B")]);
console.log("promise-all-await:", values.join(","));
}
run();You should see one line logging promise-all-await: A,B.
This is the cleaner form when you are already using async functions.
Summary
Promise.all() is the JavaScript tool for waiting on multiple promises at once. Use it when the operations can run in parallel and you only want to continue after every promise succeeds.
