API reference@evolu/commonHttp › FetchMode

type FetchMode = "text" | "json" | "bytes" | "headers";

Defined in: packages/common/src/Http.ts:52

Body mode for fetch.

A mode selects a built-in consumer that reads the Response inside the fetch Task:

  • "bytes" — reads the body as a Uint8Array<ArrayBuffer>.
  • "headers" — cancels the body and returns FetchResponse. Pair it with { method: "HEAD" } when the server should not send a body.
  • "json" — parses the body as JSON and returns unknown. Narrow or decode at the call site; there is deliberately no generic to cast through.
  • "text" — reads the body as a string.

Body modes ("bytes", "json", "text") return FetchStatusError for non-2xx responses. "headers" does not judge status, because the status is usually the value being asked for.