Type Alias: OnDownloadProgress
OnDownloadProgress = (
percent,received,total) =>ValueOrPromise<void>
Defined in: packages/fetch/src/types/options.ts:295
Callback function for monitoring download progress.
Parameters
percent
number | null
The progress percentage (0-100), or null if Content-Length is unknown.
received
number
The total number of bytes received so far.
total
number | null
The total number of bytes expected, or null if Content-Length is unknown.
Returns
ValueOrPromise<void>
Example
Download a file as Blob
javascript
import fetch from '@superutils/fetch'
fetch.get(
'[DUMMYJSON-DOT-COM]/image/4000x4000/008080/ffffff?text=Hello+@superutils', // dynamic image file
{
as: FetchAs.blob,
onDownloadProgress: (parcent, received, total) =>
console.log({
percent: `${(parcent ?? 0).toFixed(2)}%`,
received,
total,
}),
},
).then(r => console.log('result', r), console.log)