When to Use the Promise.any() method

Discover how Promise.any() executes hedge requests, and choose the fastest service.

The Promise.any() method is best used in situations where we want any one of the promises to fulfill, regardless of how many others reject, unless they all reject. Here are some situations where we might want to use Promise.any().

Executing hedged requests

A hedged request is one where the client makes requests to multiple servers and accepts the response from the first that replies. This is helpful in situations where the client needs the lowest latency possible and there are server resources devoted to managing the extra load and deduplicating responses. Here’s an example:

Get hands-on with 1200+ tech skills courses.