[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Task](https://evolu.dev/docs/api-reference/common/Task) › any

```ts
function any<T, E, D>(
  tasks: readonly [Task<T, E, D>, Task<T, E, D>],
  options?: {
    allFailed?: AnyAllFailed;
  },
): Task<T, E, D>;
```

Defined in: [packages/common/src/Task.ts:3479](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Task.ts#L3479)

Returns the first [Task](https://evolu.dev/docs/api-reference/common/Task/type-aliases/Task) that succeeds.

Like
[Promise.any](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any),
the first Task to succeed wins. All other Tasks are aborted. If all Tasks
fail, returns the last error (by input order).

Sequential by default. Use [concurrently](https://evolu.dev/docs/api-reference/common/Task/functions/concurrently) for concurrent execution.

Think of it like `Array.prototype.some()` — it stops on the first success.
This is in contrast to [race](https://evolu.dev/docs/api-reference/common/Task/functions/race), which returns the first task to complete
(whether success or failure).

### Example

```ts
// Try multiple endpoints concurrently, first success wins
const result = await run(
  concurrently(any([fetchFromPrimary, fetchFromSecondary, fetchFromTertiary])),
);
```