✌️ Create Instance Options
A couple of options are available to customize the behavior of a Z-Fetch Instance.
Here is the list of all the available options and their default values when not specified.
Careful
These Options are only applicable when setting up a Z-Fetch instance. Not supported on per request basis.
Option | Description | Use Case | Default Value |
---|---|---|---|
baseUrl | Base URL for all requests | Set a common base URL for all API requests | '' |
bearerToken | Bearer token for authentication | Authenticate requests with a bearer token | null |
timeout | Request timeout in milliseconds | Set a timeout for requests | 90000 |
retry | Whether to retry failed requests | Automatically retry failed requests | false |
maxRetries | Maximum number of retries | Set a limit on the number of retries | 3 |
startPolling | Whether to start polling automatically | Enable automatic polling | false |
stopPolling | Whether to stop polling automatically | Disable polling after certain conditions | false |
pollingInterval | Interval between polls in milliseconds | Set polling interval | 5000 |
revalidateCache | Time in milliseconds before revalidating cached data | Refresh cached data after a specific time | 10000 |
withCredentials | Whether to include credentials in requests | Include credentials like cookies | false |
withCache | Whether to use caching for GET requests | Cache GET request responses | true |
parseJson | Whether to parse response as JSON | Automatically parse JSON responses | true |
stringifyPayload | Whether to stringify request body | Automatically stringify request body | true |
mode | CORS mode for requests | Set CORS mode (e.g., 'cors', 'no-cors') | 'cors' |
headers | Default headers for all requests | Set default headers | { 'Content-Type': 'application/json', 'Accept': '*/*' } |
hooks | hooks or interceptors | Modify requests and responses on all requests | {} |
🤔 What about individual request options? See request methods for more details.
And if you think there's something missing, feel free to open an issue on our GitHub repository.