The allSettled Return Format
You'll learn how Promise.allSettled() returns results in a consistent, predictable format that differs from Promise.all().
Why a Special Format?
Unlike Promise.all() which returns just the resolved values (and short-circuits on the first rejection), Promise.allSettled() always waits for every promise to finish and gives you complete information about each one. This means it needs a way to represent both successes and failures without throwing an error.
The Result Object Structure
Promise.allSettled() returns an array where each element is an object with a status property:
For fulfilled promises:
{
status: "fulfilled",
value: /* the resolved value */
}
For rejected promises:
{
status: "rejected",
reason: /* the rejection reason/error */
}
Reading the Results
const promises = [
Promise.resolve(42),
Promise.reject(new Error("Oops")),
Promise.resolve("Done")
];
Promise.allSettled(promises).then(results => {
results.forEach((result, index) => {
if (result.status === "fulfilled") {
console.log(`Promise ${index} succeeded:`, result.value);
} else {
console.log(`Promise ${index} failed:`, result.reason.message);
}
});
});
// Output:
// Promise 0 succeeded: 42
// Promise 1 failed: Oops
// Promise 2 succeeded: Done
Notice you check the status field to know which property to read: value for success or reason for failure.
Think of It Like a Report Card
Imagine asking "Did everyone finish their homework?" Instead of stopping at the first person who didn't, you get a full report: "Student A: completed, Student B: incomplete (sick), Student C: completed." That's allSettled()'s format—a complete status report for every promise.
Key Takeaway: Promise.allSettled() returns an array of objects with status (either "fulfilled" or "rejected"), plus value for successes or reason for failures, giving you complete visibility into all outcomes.