Represents the download progress of a fetch operation.
Passed to the onProgress callback when tracking download progress. Note: Progress tracking requires the server to send a Content-Length header.
onProgress
Content-Length
import { fetchT, type FetchProgress } from '@happy-ts/fetch-t';await fetchT('https://example.com/file.zip', { responseType: 'blob', onProgress: (result) => { result.inspect((progress: FetchProgress) => { const percent = (progress.completedByteLength / progress.totalByteLength) * 100; console.log(`Downloaded: ${percent.toFixed(1)}%`); }); },}); Copy
import { fetchT, type FetchProgress } from '@happy-ts/fetch-t';await fetchT('https://example.com/file.zip', { responseType: 'blob', onProgress: (result) => { result.inspect((progress: FetchProgress) => { const percent = (progress.completedByteLength / progress.totalByteLength) * 100; console.log(`Downloaded: ${percent.toFixed(1)}%`); }); },});
The number of bytes received so far.
The total number of bytes to be received (from Content-Length header).
Represents the download progress of a fetch operation.
Passed to the
onProgresscallback when tracking download progress. Note: Progress tracking requires the server to send aContent-Lengthheader.Example