Skip to main content

Overview

ofetch.raw() returns the complete Response object along with the parsed data, giving you access to headers, status codes, and other response metadata.

Basic Usage

When to Use

Use ofetch.raw() when you need:
  • Response headers (e.g., pagination info, rate limits)
  • HTTP status codes
  • Response metadata
  • Full Response object for further processing

Response Structure

From src/types.ts:137-139:
The response object:
  • Extends the standard Response interface
  • Includes all native Response properties and methods
  • Adds _data property with the parsed body

Common Use Cases

Accessing Response Headers

Rate Limit Information

Checking Status Codes

Content Type Detection

How It Works

From src/fetch.ts:89-257:
The raw method:
  1. Creates a fetch context with request and options
  2. Processes the request (interceptors, URL building, etc.)
  3. Executes the fetch call
  4. Parses the response body into _data
  5. Returns the full Response object

Regular vs Raw Response

From src/fetch.ts:259-262:
Regular ofetch():
Raw ofetch.raw():

TypeScript Support

Using with Custom Instances

Advanced Example: Cache Headers