Fetches a resource from the network as a text string and returns an abortable FetchTask.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'text'.
A FetchTask representing the abortable operation with a string response.
Fetches a resource from the network as an ArrayBuffer and returns an abortable FetchTask.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'arraybuffer'.
A FetchTask representing the abortable operation with an ArrayBuffer response.
Fetches a resource from the network as a Blob and returns an abortable FetchTask.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'blob'.
A FetchTask representing the abortable operation with a Blob response.
Fetches a resource from the network and parses it as JSON, returning an abortable FetchTask.
The expected type of the parsed JSON data.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'json'.
A FetchTask representing the abortable operation with a response parsed as type T.
Fetches a resource from the network as a ReadableStream and returns an abortable FetchTask.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'stream'.
A FetchTask representing the abortable operation with a ReadableStream<Uint8Array<ArrayBuffer>> response.
Fetches a resource from the network as a Uint8ArrayFetchTask.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and responseType: 'bytes'.
A FetchTask representing the abortable operation with a Uint8Array<ArrayBuffer> response.
Fetches a resource from the network and returns an abortable FetchTask with a dynamic response type.
Use this overload when responseType is a FetchResponseType union type.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true and a FetchResponseType.
A FetchTask representing the abortable operation with a FetchResponseData response.
Fetches a resource from the network as a text string.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'text' and abortable must be false or omitted.
A FetchResult representing the operation with a string response.
Fetches a resource from the network as an ArrayBuffer.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'arraybuffer' and abortable must be false or omitted.
A FetchResult representing the operation with an ArrayBuffer response.
Fetches a resource from the network as a Blob.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'blob' and abortable must be false or omitted.
A FetchResult representing the operation with a Blob response.
Fetches a resource from the network and parses it as JSON.
The expected type of the parsed JSON data.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'json' and abortable must be false or omitted.
A FetchResult representing the operation with a response parsed as type T.
Fetches a resource from the network as a ReadableStream.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'stream' and abortable must be false or omitted.
A FetchResult representing the operation with a ReadableStream<Uint8Array<ArrayBuffer>> response.
Fetches a resource from the network as a Uint8Array
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include responseType: 'bytes' and abortable must be false or omitted.
A FetchResult representing the operation with a Uint8Array<ArrayBuffer> response.
Fetches a resource from the network with a dynamic response type (non-abortable).
Use this overload when responseType is a FetchResponseType union type.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation with a FetchResponseType, and abortable must be false or omitted.
A FetchResult representing the operation with a FetchResponseData response.
Fetches a resource from the network and returns an abortable FetchTask with a generic Response.
The resource to fetch. Can be a URL object or a string representing a URL.
Additional options for the fetch operation, must include abortable: true.
A FetchTask representing the abortable operation with a Response object.
Fetches a resource from the network and returns a FetchResult with a generic Response object.
The resource to fetch. Can be a URL object or a string representing a URL.
Optionalinit: FetchInit & { abortable?: false }Optional additional options for the fetch operation, and abortable must be false or omitted.
A FetchResult representing the operation with a Response object.
Enhanced fetch function that wraps the native Fetch API with additional capabilities.
Features:
abortable: trueto get aFetchTaskwithabort()method.responseTypeto automatically parse responses as text, JSON, ArrayBuffer, Blob, bytes, or stream.timeoutin milliseconds to auto-abort long-running requests.onProgresscallback to track download progress (requires Content-Length header).onChunkcallback to receive raw data chunks as they arrive.retryto automatically retry failed requests with configurable delay and conditions.Result<T, Error>instead of throwing exceptions for runtime errors.Note: Invalid parameters throw synchronously (fail-fast) rather than returning rejected Promises. This differs from native
fetchbehavior and helps catch programming errors during development.Type Param: T
The expected type of the response data.
Param: url
The resource to fetch. Can be a URL object or a string representing a URL.
Param: init
Additional options for the fetch operation, extending standard
RequestInitwith custom properties.Returns
A
FetchTask<T>ifabortable: true, otherwise aFetchResult<T>(which isAsyncIOResult<T>).Throws
If
urlis invalid or a relative URL in non-browser environment.Throws
If
responseTypeis not a valid response type.Throws
If
timeoutis not a number.Throws
If
timeoutis not greater than 0.Throws
If
onProgressoronChunkis provided but not a function.Throws
If
retry.retriesis not an integer.Throws
If
retry.retriesis negative.Throws
If
retry.delayis not a number or function.Throws
If
retry.delayis a negative number.Throws
If
retry.whenis not an array or function.Throws
If
retry.onRetryis provided but not a function.Example
Example
Example
Example
Example
Example
Example