ofetch@1.3.3 - jsDocs.io

A better fetch API. Works on node, browser and workers.

Index
Variables
$fetch
AbortController
fetch
Headers
ofetch
Functions
createFetch()
createFetchError()
Classes
FetchError
Interfaces
$Fetch
CreateFetchOptions
FetchContext
FetchError
FetchOptions
FetchResponse
IFetchError
SearchParameters
Type Aliases
FetchRequest
Variables
variable $fetch
const $fetch: $Fetch;
variable AbortController
const AbortController: { new (): AbortController; prototype: AbortController };
variable fetch
const fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
variable Headers
const Headers: { new (init?: HeadersInit | undefined): Headers; prototype: Headers };
variable ofetch
const ofetch: $Fetch;
Functions
function createFetch
createFetch: (globalOptions?: CreateFetchOptions) => $Fetch;
function createFetchError
createFetchError: <T = any>(ctx: FetchContext<T>) => IFetchError<T>;
Classes
class FetchError
class FetchError<T = any> extends Error implements IFetchError<T> {}
constructor
constructor(message: string, opts?: { cause: unknown });
Interfaces
interface $Fetch
interface $Fetch {}
property native
native: Fetch;
method create
create: (defaults: FetchOptions) => $Fetch;
method raw
raw: <T = any, R extends ResponseType = 'json'>(
    request: FetchRequest,
    options?: FetchOptions<R>
) => Promise<FetchResponse<MappedType<R, T>>>;
call signature
<T = any, R extends ResponseType = 'json'>(
    request: FetchRequest,
    options?: FetchOptions<R>
): Promise<MappedType<R, T>>;
interface CreateFetchOptions
interface CreateFetchOptions {}
property AbortController
AbortController?: typeof AbortController;
property defaults
defaults?: FetchOptions;
property fetch
fetch?: Fetch;
property Headers
Headers?: typeof Headers;
interface FetchContext
interface FetchContext<T = any, R extends ResponseType = ResponseType> {}
property error
error?: Error;
property options
options: FetchOptions<R>;
property request
request: FetchRequest;
property response
response?: FetchResponse<T>;
interface FetchError
interface FetchError<T = any> extends IFetchError<T> {}
interface FetchOptions
interface FetchOptions<R extends ResponseType = ResponseType>
    extends Omit<RequestInit, 'body'> {}
property baseURL
baseURL?: string;
property body
body?: RequestInit['body'] | Record<string, any>;
property duplex
duplex?: 'half' | undefined;

Set to "half" to enable duplex streaming. Will be automatically set to "half" when using a ReadableStream as body. https://fetch.spec.whatwg.org/#enumdef-requestduplex

Modifiers
@experimental
property ignoreResponseError
ignoreResponseError?: boolean;
property params
params?: SearchParameters;
property parseResponse
parseResponse?: (responseText: string) => any;
property query
query?: SearchParameters;
property responseType
responseType?: R;
property retry
retry?: number | false;
property retryDelay
retryDelay?: number;

Delay between retries in milliseconds.

property retryStatusCodes
retryStatusCodes?: number[];

Default is [408, 409, 425, 429, 500, 502, 503, 504]

property timeout
timeout?: number;

timeout in milliseconds

method onRequest
onRequest: (context: FetchContext) => Promise<void> | void;
method onRequestError
onRequestError: (
    context: FetchContext & { error: Error }
) => Promise<void> | void;
method onResponse
onResponse: (
    context: FetchContext & { response: FetchResponse<R> }
) => Promise<void> | void;
method onResponseError
onResponseError: (
    context: FetchContext & { response: FetchResponse<R> }
) => Promise<void> | void;
interface FetchResponse
interface FetchResponse<T> extends Response {}
interface IFetchError
interface IFetchError<T = any> extends Error {}
property data
data?: T;
property options
options?: FetchOptions;
property request
request?: FetchRequest;
property response
response?: FetchResponse<T>;
property status
status?: number;
property statusCode
statusCode?: number;
property statusMessage
statusMessage?: string;
property statusText
statusText?: string;
interface SearchParameters
interface SearchParameters {}
index signature
[key: string]: any;
Type Aliases
type FetchRequest
type FetchRequest = RequestInfo;
Package Files (2)
dist/index.d.ts
dist/shared/ofetch.441891d5.d.ts
Dependencies (3)
destr
node-fetch-native
ufo
Dev Dependencies (15)
@types/node
@vitest/coverage-v8
changelogen
eslint
eslint-config-unjs
fetch-blob
formdata-polyfill
h3
jiti
listhen
prettier
std-env
typescript
unbuild
vitest
Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this oneto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ofetch.

Markdown
[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ofetch)
HTML
<a href="https://www.jsdocs.io/package/ofetch"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
Updated 3 months ago.
Package analyzed in 3596 ms.
Missing or incorrect documentation? Open an issue for this package.
Back to top