JavaScript Promise API Reference

Promise methods, combinators and async/await patterns in one searchable table

Reference for the JavaScript Promise API: instance methods then, catch, finally and the static combinators all, allSettled, any, race, resolve, reject, with their fulfillment and rejection rules and async/await equivalents.

Difference between Promise.all and Promise.allSettled?

Promise.all rejects as soon as any input promise rejects and discards the other results, so it is all-or-nothing. Promise.allSettled never rejects; it waits for every promise and returns an array of objects each describing fulfilled with a value or rejected with a reason. Use allSettled when partial failures are acceptable.

The Promise API is small but each combinator has a precise rule for when it fulfills and when it rejects, and choosing the wrong one causes silent data loss or unhandled rejections. This reference lists every Promise method with its settlement rule and the equivalent async/await pattern.

How it works

A Promise is in one of three states: pending, fulfilled, or rejected. Instance methods register callbacks:

  • then(onFulfilled, onRejected) transforms the value or handles rejection.
  • catch(onRejected) is shorthand for then(undefined, onRejected).
  • finally(onFinally) runs on either outcome and passes the result through.

The static combinators take an iterable of promises and differ only in their settlement rule:

Promise.all        // fulfills with all values; rejects on first rejection
Promise.allSettled // never rejects; array of {status, value|reason}
Promise.any        // first fulfillment; AggregateError if all reject
Promise.race       // first to settle, fulfill OR reject, wins

Tips

Use all when you need every result and any failure should abort the batch; use allSettled when partial failure is fine and you want to inspect each outcome. Reach for any to get the first success across redundant sources, and race to enforce a timeout (Promise.race([work, timeout])). Always attach a catch or await inside try/catch — an unhandled rejection crashes Node and logs a warning in browsers.