Skip to content
0

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 ParameterDefault typeDescription
TanyThe 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 ​

PropertyTypeDescriptionInherited fromDefined in
body?BodyInit | nullA BodyInit object or null to set request's body.RequestInit.bodynode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2554
cache?RequestCacheA string indicating how the request will interact with the browser's cache to set request's cache.RequestInit.cachenode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2556
credentials?RequestCredentialsA 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.credentialsnode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2558
headers?HeadersInitA Headers object, an object literal, or an array of two-item arrays to set request's headers.RequestInit.headersnode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2560
ignoreDefaultQuery?booleanSkip the endpoint's defaultQueryParams instead of merging them.-src/types/index.ts:417
integrity?stringA cryptographic hash of the resource to be fetched by request. Sets request's integrity.RequestInit.integritynode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2562
keepalive?booleanA boolean to set request's keepalive.RequestInit.keepalivenode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2564
method?stringA string to set request's method.RequestInit.methodnode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2566
mode?RequestModeA string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.RequestInit.modenode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2568
params?PathParamsPath params substituted into :name placeholders of the endpoint.-src/types/index.ts:413
priority?RequestPriority-RequestInit.prioritynode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2569
query?QueryParamsQuery-string params appended to the URL.-src/types/index.ts:415
redirect?RequestRedirectA 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.redirectnode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2571
referrer?stringA string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.RequestInit.referrernode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2573
referrerPolicy?ReferrerPolicyA referrer policy to set request's referrerPolicy.RequestInit.referrerPolicynode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2575
signal?AbortSignal | nullAn AbortSignal to set request's signal.RequestInit.signalnode_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?nullCan only be null. Used to disassociate request from any Window.RequestInit.windownode_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:2579

Released under the MIT License.