Installation
The Fetch client is included in the main@hey-api/openapi-ts package. To use it standalone:
Basic Usage
Configuration
The Fetch client supports comprehensive configuration options:Client Options
Runtime Configuration
Update client configuration after creation:HTTP Methods
The client provides methods for all HTTP verbs:- GET
- POST
- PUT
- PATCH
- DELETE
- HEAD
- OPTIONS
Authentication
The Fetch client supports multiple authentication schemes:Bearer Token
Basic Authentication
API Key
Interceptors
Add request, response, and error interceptors:Request Interceptor
Response Interceptor
Error Interceptor
Response Parsing
Control how responses are parsed:Auto (Default)
JSON
Text
Blob
Stream
Server-Sent Events
Stream real-time data with Server-Sent Events:Body Serialization
Customize how request bodies are serialized:JSON (Default)
FormData
URL Encoded
Query Serialization
Customize query parameter serialization:Advanced Examples
Custom Fetch Implementation
Request Cancellation
Response Validation
Response Transformation
TypeScript Types
Import client types for advanced usage:Next Steps
Axios Client
Advanced features with Axios
Authentication
Set up API authentication
Interceptors
Add request/response interceptors
Error Handling
Handle errors effectively