⚡ Z-Fetch

✌️ 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.

OptionDescriptionUse CaseDefault Value
baseUrlBase URL for all requestsSet a common base URL for all API requests''
bearerTokenBearer token for authenticationAuthenticate requests with a bearer tokennull
timeoutRequest timeout in millisecondsSet a timeout for requests90000
retryWhether to retry failed requestsAutomatically retry failed requestsfalse
maxRetriesMaximum number of retriesSet a limit on the number of retries3
startPollingWhether to start polling automaticallyEnable automatic pollingfalse
stopPollingWhether to stop polling automaticallyDisable polling after certain conditionsfalse
pollingIntervalInterval between polls in millisecondsSet polling interval5000
revalidateCacheTime in milliseconds before revalidating cached dataRefresh cached data after a specific time10000
withCredentialsWhether to include credentials in requestsInclude credentials like cookiesfalse
withCacheWhether to use caching for GET requestsCache GET request responsestrue
parseJsonWhether to parse response as JSONAutomatically parse JSON responsestrue
stringifyPayloadWhether to stringify request bodyAutomatically stringify request bodytrue
modeCORS mode for requestsSet CORS mode (e.g., 'cors', 'no-cors')'cors'
headersDefault headers for all requestsSet default headers{ 'Content-Type': 'application/json', 'Accept': '*/*' }
hookshooks or interceptorsModify requests and responses on all requests{}
useXHRForProgressForce XMLHttpRequest for progress trackingForce XHR usage even without progress callbacksfalse
credentialsCredentials mode for requestsSet credentials mode ('include', 'same-origin', 'omit')undefined
cacheCache mode for requestsSet cache mode ('default', 'no-store', 'reload', etc.)undefined
signalAbortSignal for request cancellationCancel requests using AbortController signalundefined

🤔 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.