katanakit-js / FetchOptions
Interface: FetchOptions<T>
Defined in: src/types/index.ts:411
Options passed when executing a fetch request.
URL building lives at the top level — the same shape as useGet, useRequest and Nuxt's useFetch — so nothing has to be nested:
ts
useFetch("api", "byId", { method: "GET", params: { id: 25 }, query: { limit: 2 } });Extends
RequestInit
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T | any | The type FetchOptions.transform resolves to. Defaults to any on purpose: with unknown a bare FetchOptions (or one stored in a variable / passed through a wrapper) would no longer be assignable to FetchOptions<T>, which is a type-level break for existing callers. |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
body? | BodyInit | null | A BodyInit object or null to set request's body. | RequestInit.body | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2554 |
cache? | RequestCache | A string indicating how the request will interact with the browser's cache to set request's cache. | RequestInit.cache | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2556 |
credentials? | RequestCredentials | A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. | RequestInit.credentials | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2558 |
headers? | HeadersInit | A Headers object, an object literal, or an array of two-item arrays to set request's headers. | RequestInit.headers | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2560 |
ignoreDefaultQuery? | boolean | Skip the endpoint's defaultQueryParams instead of merging them. | - | src/types/index.ts:417 |
integrity? | string | A cryptographic hash of the resource to be fetched by request. Sets request's integrity. | RequestInit.integrity | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2562 |
keepalive? | boolean | A boolean to set request's keepalive. | RequestInit.keepalive | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2564 |
method? | string | A string to set request's method. | RequestInit.method | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2566 |
mode? | RequestMode | A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. | RequestInit.mode | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2568 |
params? | PathParams | Path params substituted into :name placeholders of the endpoint. | - | src/types/index.ts:413 |
priority? | RequestPriority | - | RequestInit.priority | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2569 |
query? | QueryParams | Query-string params appended to the URL. | - | src/types/index.ts:415 |
redirect? | RequestRedirect | A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. | RequestInit.redirect | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2571 |
referrer? | string | A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. | RequestInit.referrer | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2573 |
referrerPolicy? | ReferrerPolicy | A referrer policy to set request's referrerPolicy. | RequestInit.referrerPolicy | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2575 |
signal? | AbortSignal | null | An AbortSignal to set request's signal. | RequestInit.signal | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2577 |
transform? | (input) => T | Promise<T> | Maps the parsed response body to T before it is returned. | - | src/types/index.ts:427 |
window? | null | Can only be null. Used to disassociate request from any Window. | RequestInit.window | node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2579 |