Skip to main content
Version: 0.1.2

Interface: FetchStateConfig

Imported from @react-logic/utils

Common config fields shared by fetchState and callableFetchState. Mirrors RequestInit so method, headers, credentials, etc. land directly on the config object — plus the wrapper-specific parse and fetcher fields. Plain-object bodies are auto-stringified.

Extends

  • Omit<RequestInit, "signal" | "window" | "body">

Extended by

Type Parameters

T

T = unknown

The parsed response type.

Properties

body?

optional body?: FetchStateBody

Plain objects/arrays are JSON-stringified; BodyInit values pass through untouched.


fetcher?

optional fetcher?: FetchAdapter

Per-call HTTP adapter, overriding the global one set via setFetchStateAdapter.


parse?

optional parse?: (response) => Promise<T>

How to turn the response into the value. Defaults to a function that throws when !ok and returns r.json() as T otherwise. Throw inside parse to land in the failed state with that error and the response's status.

Parameters

Returns

Promise<T>