The URL to fetch.
Optional
config: RequestConfigThe configuration options for the request.
A Promise that resolves to the response.
Performs a DELETE request.
The request path.
Optional request configuration.
A Promise resolving to the Response.
Downloads a file while reporting progress.
The request path.
Callback for download progress.
Optional request configuration.
A Promise resolving to the downloaded Blob.
fetcher.downloadWithProgress('/file.zip', (loaded, total) => {
const percentComplete = total ? (loaded / total) * 100 : 0;
console.log(`Download progress: ${percentComplete}%`);
})
.then(blob => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'file.zip';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
})
.catch(err => console.error(err));
Performs a GET request and parses JSON.
The request path.
Optional request configuration.
A Promise resolving to the Response.
Performs a POST request with a JSON body.
The request path.
The JSON payload.
Optional request configuration.
A Promise resolving to the Response.
Performs a POST request with upload progress reporting using XHR.
The request path.
The payload to upload.
Callback for upload progress.
Optional request configuration.
A Promise resolving to the Response.
Performs a PUT request with a JSON body.
The request path.
The JSON payload.
Optional request configuration.
A Promise resolving to the response.
Create a new Fetcher instance with the given configuration.
The configuration options for the Fetcher instance.
A new Fetcher instance.
Create a new Fetcher instance with the given configuration.