🤝 All Options
Complete guide to instance configuration options and request-level settings.
Z-Fetch provides comprehensive configuration options that can be set at the instance level for consistent behavior across all requests, or at the request level for specific customization.
Instance Configuration
Set default options when creating an instance:
Core Configuration Options
Base URL
Set a base URL for all requests:
Headers
Set default headers for all requests:
Headers are intelligently merged:
Authentication
Bearer Token
Automatic Bearer token authentication:
Basic Authentication
API Key Authentication
Credentials and CORS
Control how credentials are sent with requests:
- Fetch path: sets
credentials: 'include'. - XHR path (when using progress callbacks): sets
xhr.withCredentials = true.
Advanced Configuration
Timeout
Set request timeout in milliseconds:
Retry Configuration
Configure automatic retries for failed requests:
Cache Configuration
Control request and response caching:
- Successful GET responses are cached when
withCache: true. - Failed or canceled GETs are not cached; the next call hits the network.
- Background revalidation preserves existing cache on failure.
Progress Tracking Configuration
Upload Progress
Download Progress
Error Configuration
Error Mapping
Map error codes and messages to user-friendly text:
Error Handling
Request/Response Processing
JSON Handling
Control automatic JSON parsing:
Response Processing
Environment-Based Configuration
Development vs Production
Configuration Loading
Complete Configuration Example
Request-Level Overrides
Any instance configuration can be overridden at the request level:
Configuration Priority
Request-level options always take precedence over instance-level options.