Skip to main content

Overview

The createFetch function allows you to create customized instances of ofetch with predefined defaults and global options.

Type Signature

Usage

Parameters

CreateFetchOptions
Global configuration for the fetch instance
$Fetch
A new ofetch instance. See ofetch.

CreateFetchOptions

defaults

FetchOptions
Default FetchOptions to apply to all requests made with this instance. These can be overridden on a per-request basis.

fetch

Fetch
Custom fetch implementation to use instead of globalThis.fetch. Useful for providing polyfills or custom fetch behavior.

Examples

API Client with Authentication

Custom Retry Configuration

Node.js with Custom Fetch