Documentation Index
Fetch the complete documentation index at: https://mintlify.com/unjs/ofetch/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ofetch is the main function exported by the library. It provides a modern, type-safe interface for making HTTP requests with automatic response parsing, error handling, and retry logic.
The $fetch alias is also available and functionally identical to ofetch.
Type Signature
Usage
Basic Request
The URL or Request object to fetch
Request options and configuration. See FetchOptions for details.
Returns a promise that resolves to the parsed response data based on the
responseTypeMethods
ofetch()
The main function that returns parsed response data.URL string or Request object
Request configuration options
Parsed response data (JSON by default)
ofetch.raw()
Returns the full Response object with parsed data available in_data property.
URL string or Request object
Request configuration options
Full Response object with
_data property containing parsed response. See FetchResponse.ofetch.native()
Access to the nativefetch function used internally.
Standard fetch API arguments
Native fetch Response object
ofetch.create()
Create a newofetch instance with custom default options.
Default options to apply to all requests made with this instance. See FetchOptions.
Global configuration options. See createFetch.
A new ofetch instance with the provided defaults
Type Parameters
The expected type of the response data
The response type:
"json", "text", "blob", "arrayBuffer", or "stream". See ResponseType.Related Types
- FetchOptions - Request configuration options
- FetchResponse - Response interface
- ResponseType - Available response types
- CreateFetchOptions - Instance creation options