API reference@evolu/commonTask › fetch

function fetch(
  input: RequestInfo | URL,
  init?: RequestInit,
): Task<Response, FetchError>;

Defined in: packages/common/src/Task.ts:3806

Creates a Task that wraps the native Fetch API.

Handles cross-browser abort behavior — WebKit throws a DOMException with message "Fetch is aborted" instead of propagating signal.reason. This helper normalizes the behavior to always return AbortError.

Example

await using run = createRun();

const result = await run(fetch("https://api.example.com/users"));

if (!result.ok) {
  // Handle FetchError or AbortError
}

// Compose with timeout and retry
const fetchWithRetry = (url: string) =>
  retry(timeout(fetch(url), "10s"), retryStrategyAws);