OptionalabortableWhen true, returns a FetchTask instead of FetchResult.
The FetchTask provides abort() method and aborted status.
OptionalonCallback invoked when a chunk of data is received.
Useful for streaming or processing data as it arrives.
Each chunk is a Uint8Array<ArrayBuffer> containing the raw bytes.
Note: This feature uses response.clone() internally. The cloned stream shares
the same underlying data source (via tee()), so it does NOT double memory usage.
However, if the two streams consume data at different speeds, chunks may be buffered
temporarily until both streams have read them.
The raw data chunk received from the response stream.
OptionalonCallback invoked during download to report progress.
Receives an IOResult<FetchProgress>:
Ok(FetchProgress) - Progress update with byte countsErr(Error) - If Content-Length header is missing (called once)Note: This feature uses response.clone() internally. The cloned stream shares
the same underlying data source (via tee()), so it does NOT double memory usage.
However, if the two streams consume data at different speeds, chunks may be buffered
temporarily until both streams have read them.
The progress result, either success with progress data or error.
OptionalresponseSpecifies how the response body should be parsed.
'text' - Returns string'json' - Returns parsed JSON (type T)'arraybuffer' - Returns ArrayBuffer'bytes' - Returns Uint8Array<ArrayBuffer> (with fallback for older environments)'blob' - Returns Blob'stream' - Returns ReadableStream<Uint8Array<ArrayBuffer>>undefined - Returns raw Response objectWhen using a dynamic string value (not a literal type), the return type
will be FetchResponseData (union of all possible types).
OptionalretryRetry options.
Can be a number (shorthand for retries count) or an options object.
// Retry up to 3 times on network errors
const result = await fetchT('https://api.example.com/data', {
retry: 3,
});
// Detailed configuration
const result = await fetchT('https://api.example.com/data', {
retry: {
retries: 3,
delay: 1000,
when: [500, 502],
onRetry: (error, attempt) => console.log(error),
},
});
OptionaltimeoutMaximum time in milliseconds to wait for the request to complete.
If exceeded, the request is automatically aborted with a TimeoutError.
Must be a positive number.
Extended fetch options that add additional capabilities to the standard
RequestInit.Since
1.0.0
Example