bestfetchInitiates an HTTP request.
import { bestfetch } from 'bestfetch';url. The URL of the request.options]. An object that allows you to configure the request. No options are required. Supported options are:method: The HTTP method of the request.body: The body of the request; typically a string.headers: An object of HTTP headers to include in the request.dedupe: Whether or not to deduplicate the request. Defaults to true. Learn more herecachePolicy: Determines how the cache will be used, if at all. Defaults to "cache-first". Valid values are "cache-first", "network-only", and "cache-only". Learn more here.responseType: The responseType option of the request. Defaults to "json". Valid values are "json", "text", "formData", "blob", and "arrayBuffer". Learn more here.requestKey: Optional. Learn more here.Additional, less commonly used options come from fetch:
modecredentialscache (note: this is unrelated to the caching system of bestfetch)redirectreferrerreferrerPolicyintegritykeepalivesignalTo learn more about the options that come from fetch, refer to the MDN documentation.
A Promise that resolves once the response is received from the server or cache. It rejects otherwise.
bestfetch('https://jsonplaceholder.typicode.com/todos/1')
.then(res => {
console.log('Got some data', res.data);
});More examples, as well as guidance on usage, can be found in the Making Requests guide.