The key which is used if an authentication token is persisted via cookies, localStorage or sessionStorage
Specifies how soFetch should send authentication credentials to the server
The key which is used if an authentication token is sent to the server via a custom header
The key which is used if an authentication token is sent to the server via the query string
Specifies how (or if) soFetch should persist and authentication
The base URL for all HTTP requests in the instance. If absent this is assumed to be the current base url. If running in Node relative requests without a baseUrl will throw an error.
ProtectedbeforeProtectedbeforeProtectedonAdds a handler which will be executed before every request. beforeSend handlers on the config will be executed before request-specific handlers
soFetch.config.beforeSend((req:SoFetchRequest) => {
console.info(`Sending ${req.method} request to URL ${req.url}`
})
For more examples see https://sofetch.antoinette.agency
Adds a handler which will be executed before every request. beforeSend handlers on the config will be executed before request-specific handlers
soFetch.config.beforeSend((req:SoFetchRequest) => {
console.info(`Sending ${req.method} request to URL ${req.url}`
})
For more examples see https://sofetch.antoinette.agency
Adds a handler which will be executed on receipt from the server of the specified status code. Multiple handlers will be executed in the order in which they are added. If a request has it's own handler(s) for a given status code the corresponding handlers in the config will not be executed.
An HTTP status code
A function which accepts a Fetch Response as an argument
For more examples see https://sofetch.antoinette.agency
ProtectedgetAdds a handler which will be executed after every request. Handlers will fire regardless of whether the response status code indicated an error
soFetch.config.onRequestComplete((r: Response) => {
console.info(`Response received from ${r.url} with status ${r.status}`
})
For more examples see https://sofetch.antoinette.agency
Use this method to set an auth token after it's been received from a server, typically as the response to a login request
Tells soFetch to use basic authorization when communicating with the server
Tells soFetch to use bearer authentication to send an authentication token to the server
Tells soFetch to authenticate using cookies.
Optionalprops: { authenticationKey?: string; authToken?: string }Tells soFetch to send an authentication token to the server
Tells soFetch to send append an authentication token to the request query string
Configures all requests for a specific soFetch instance