Promise.any()

noun

say it: “PROM-is EN-ee” /ˈprɑmɪs ˈɛni/

A method that gives back the value of the first promise in a list that works, and fails only if every one of them fails.

What does Promise.any() do in JavaScript?

Promise.any() — A method returning the first fulfilled input or rejecting if all inputs reject.

const firstSuccess = await Promise.any(requests);

In a sentence

  • “Promise.any() only rejected when all three backup servers were down.”
  • “The pizza tracker asks three drivers at once, and Promise.any() picks the first one who says yes.”

Level: Freelancer · More JavaScript terms at this level

Updated