Skip to content

fetchWithProgress

function fetchWithProgress(input, init?): Promise<Response>;

Defined in: fetch-with-progress.ts:45

Drop-in fetch replacement that adds upload/download progress tracking. Compatible with Eden Treaty’s fetcher option.

Parameter Type
input RequestInfo | URL
init? FetchWithProgressInit

Promise<Response>

const client = treaty<App>(url, {
fetcher: fetchWithProgress as typeof fetch,
fetch: { credentials: "include" },
});
// With progress:
await client.api.upload.post(formData, {
onProgress: ({ direction, transferred, total }) => {
console.log(`${direction}: ${transferred}/${total}`);
},
});