OptionalbodyA BodyInit object or null to set request's body.
OptionalcacheA string indicating how the request will interact with the browser's cache to set request's cache.
Optionalcomplete接口调用结束的回调函数(调用成功、失败都会执行)
OptionalcredentialsA string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
Optionalenable需要基础库: 2.10.4
是否开启 http2
Optionalenable需要基础库: 3.5.0
是否开启 profile。iOS 和 Android 端默认开启,其他端暂不支持。开启后可在接口回调的 res.profile 中查看性能调试信息。
Optionalenable需要基础库: 2.10.4
是否开启 Quic/h3 协议(iOS 微信目前使用 gQUIC-Q43;Android 微信在 v8.0.54 前使用 gQUIC-Q43,v8.0.54 开始使用 IETF QUIC,即 h3 协议;PC微信使用 IETF QUIC,即 h3 协议)
OptionalfilenameThe filename to use when uploading the file.
OptionalformHTTP 请求中其他额外的 form data
OptionalheadersOptionalintegrityA cryptographic hash of the resource to be fetched by request. Sets request's integrity.
OptionalkeepaliveA boolean to set request's keepalive.
OptionalmethodA string to set request's method.
OptionalmodeA string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
Optionalname可选的文件名称。
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.
OptionalpriorityOptionalredirectA string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
OptionalreferrerA string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
OptionalreferrerA referrer policy to set request's referrerPolicy.
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),
},
});
OptionalsignalAn AbortSignal to set request's signal.
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.
OptionalwindowCan only be null. Used to disassociate request from any Window.
统一上传请求的选项。
Since
1.0.0
Example