HTTP, HTTPS, data:, and IPFS:.
Additional schemes can be added globally using registerGateway.
Example
Implements
Iterable<[string,string]>
Constructors
new FetchRequest()
.send() to make the request.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
FetchRequest
Source
utils/fetch.ts:503Accessors
allowGzip
Returns
boolean
Source
utils/fetch.ts:413allowInsecureAuthentication
Authentication credentials to be sent over insecure channels. (default: false)
Returns
boolean
Source
utils/fetch.ts:423body
Content-Type is automatically set and will be used if not overridden by
setting a custom header.
If body is null, the body is cleared (along with the intrinsic Content-Type).
If body is a string, the intrinsic Content-Type is set to text/plain.
If body is a Uint8Array, the intrinsic Content-Type is set to application/octet-stream.
If body is any other object, the intrinsic Content-Type is set to application/json.
Returns
null | Uint8Array
Source
utils/fetch.ts:265credentials
Authorization header.
To set the credentials, use the setCredentials method.
Returns
null | string
Source
utils/fetch.ts:394getUrlFunc
null will cause this
FetchRequest (and any future clones) to revert back to using the currently registered global getUrl function.
Setting this is generally not necessary, but may be useful for developers that wish to intercept requests or to
configurege a proxy or other agent.
Returns
FetchGetUrlFunc
Source
utils/fetch.ts:491headers
FetchRequest.
To set a header entry, use the setHeader method.
Returns
Record<string, string>
Source
utils/fetch.ts:323method
GET is used if the
body is null and POST otherwise.
Returns
string
Source
utils/fetch.ts:300preflightFunc
Returns
null | FetchPreflightFunc
Source
utils/fetch.ts:447processFunc
send() to throw.
To schedule a retry attempt (assuming the maximum retry limit has not been reached), use
FetchResponse.throwThrottleError.
Returns
null | FetchProcessFunc
Source
utils/fetch.ts:463retryFunc
Returns
null | FetchRetryFunc
Source
utils/fetch.ts:473timeout
Returns
number
Source
utils/fetch.ts:433url
Returns
string
Source
utils/fetch.ts:244Methods
cancel()
CANCELLED error to be rejected from the
send.
Returns
void
Source
utils/fetch.ts:656clearHeaders()
Returns
void
Source
utils/fetch.ts:367clone()
Returns
FetchRequest
The new request.
Source
utils/fetch.ts:709getHeader()
key, ignoring case.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The header key to retrieve. |
Returns
string
The header value.
Source
utils/fetch.ts:350hasBody()
Returns
this is FetchRequest & Object
Source
utils/fetch.ts:292redirect()
location.
Parameters
| Parameter | Type | Description |
|---|---|---|
location | string | The location to redirect to. |
Returns
FetchRequest
The new request.
Source
utils/fetch.ts:673send()
Returns
Promise<FetchResponse>
Source
utils/fetch.ts:644setCredentials()
Authorization for username with password.
Parameters
| Parameter | Type | Description |
|---|---|---|
username | string | The username to use for basic authentication. |
password | string | The password to use for basic authentication. |
Returns
void
Throws
If theusername contains a colon.
Source
utils/fetch.ts:405setHeader()
key to value. All values are coerced to a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The header key to set. |
value | string | number | The header value to set. |
Returns
void
Source
utils/fetch.ts:360setThrottleParams()
Parameters
| Parameter | Type | Description |
|---|---|---|
params | FetchThrottleParams | The throttle parameters to set. |
Returns
void
Throws
If theslotInterval is not a positive integer.
Source
utils/fetch.ts:530createDataGateway()
Returns
FetchGatewayFunc
The gateway function.
Source
utils/fetch.ts:827createGetUrlFunc()
options are dependent on the platform implementation of the default getUrl function.
This is not generally something that is needed, but is useful when trying to customize simple behaviour when
fetching HTTP content.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | Record<string, any> | The options to use when creating the getUrl function. |
Returns
FetchGetUrlFunc
The getUrl function.
Throws
If the gateways are locked.Source
utils/fetch.ts:813createIpfsGatewayFunc()
"https://gateway.ipfs.io/ipfs/".
Parameters
| Parameter | Type | Description |
|---|---|---|
baseUrl | string | The base URL of the IPFS gateway. |
Returns
FetchGatewayFunc
The gateway function.
Source
utils/fetch.ts:839getGateway()
scheme.
Parameters
| Parameter | Type | Description |
|---|---|---|
scheme | string | The scheme to get the gateway for. |
Returns
null | FetchGatewayFunc
The gateway function, or null if not found.
Source
utils/fetch.ts:758lockConfig()
Returns
void
Source
utils/fetch.ts:748registerGateway()
func when fetching URIs using scheme.
This method affects all requests globally.
If lockConfig has been called, no change is made and this throws.
Parameters
| Parameter | Type | Description |
|---|---|---|
scheme | string | The scheme to register the gateway for. |
func | FetchGatewayFunc | The gateway function to use. |
Returns
void
Throws
If the scheme ishttp or https.
Source
utils/fetch.ts:773registerGetUrl()
getUrl when fetching URIs over HTTP and HTTPS requests.
This method affects all requests globally.
If lockConfig has been called, no change is made and this throws.
Parameters
| Parameter | Type | Description |
|---|---|---|
getUrl | FetchGetUrlFunc | The function to use for fetching HTTP and HTTPS URIs. |
Returns
void
