Promise.race and Promise.any

Promise.race settles like the first promise to finish, success or failure. Promise.any settles on the first one that succeeds and only rejects if all of them fail. race is used, for example, to impose a maximum delay, and any to take the fastest response among several sources.

Example

const premier = await Promise.any([serveurA(), serveurB()])

Related concepts

The whole glossary