On this page
  1. Promise.any
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Promise.any

Prev: race | Up: Promise | Next: withResolvers
Rel: Promise, Promise & Async Guide
Ref: MDN Web Docs — Promise.any
Tags: #public #web #javascript #builtins #promise #tier/standard


Signature & Overview

Promise.any(iterable)

Fulfills with the first fulfilled promise; rejects with AggregateError only if all reject.

Notes & Pitfalls

Example

const winner = await Promise.any([
  Promise.reject(new Error("fail")),
  Promise.resolve("backup"),
]);
console.assert(winner === "backup");

Linked from

Related notes