HTTP
, HTTPS
, data:
, and IPFS:
.
Additional schemes can be added globally using registerGateway.
Iterable
<[string
, string
]>.send()
to make the request.
Parameter | Type |
---|---|
url | string |
FetchRequest
boolean
Authentication
credentials to be sent over insecure channels. (default: false)
boolean
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
.
null
| Uint8Array
Authorization
header.
To set the credentials, use the setCredentials
method.
null
| string
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.
FetchGetUrlFunc
FetchRequest
.
To set a header entry, use the setHeader
method.
Record
<string
, string
>
GET
is used if the
body is null and POST
otherwise.
string
null
| FetchPreflightFunc
send()
to throw.
To schedule a retry attempt (assuming the maximum retry limit has not been reached), use
FetchResponse.throwThrottleError.
null
| FetchProcessFunc
null
| FetchRetryFunc
number
string
CANCELLED
error to be rejected from the
send.
void
void
FetchRequest
The new request.
key
, ignoring case.
Parameter | Type | Description |
---|---|---|
key | string | The header key to retrieve. |
string
The header value.
this is FetchRequest & Object
location
.
Parameter | Type | Description |
---|---|---|
location | string | The location to redirect to. |
FetchRequest
The new request.
Promise
<FetchResponse
>
Authorization
for username
with password
.
Parameter | Type | Description |
---|---|---|
username | string | The username to use for basic authentication. |
password | string | The password to use for basic authentication. |
void
username
contains a colon.
key
to value
. All values are coerced to a string.
Parameter | Type | Description |
---|---|---|
key | string | The header key to set. |
value | string | number | The header value to set. |
void
Parameter | Type | Description |
---|---|---|
params | FetchThrottleParams | The throttle parameters to set. |
void
slotInterval
is not a positive integer.
FetchGatewayFunc
The gateway function.
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.
Parameter | Type | Description |
---|---|---|
options ? | Record <string , any > | The options to use when creating the getUrl function. |
FetchGetUrlFunc
The getUrl function.
"https://gateway.ipfs.io/ipfs/"
.
Parameter | Type | Description |
---|---|---|
baseUrl | string | The base URL of the IPFS gateway. |
FetchGatewayFunc
The gateway function.
scheme
.
Parameter | Type | Description |
---|---|---|
scheme | string | The scheme to get the gateway for. |
null
| FetchGatewayFunc
The gateway function, or null if not found.
void
func
when fetching URIs using scheme
.
This method affects all requests globally.
If lockConfig has been called, no change is made and this throws.
Parameter | Type | Description |
---|---|---|
scheme | string | The scheme to register the gateway for. |
func | FetchGatewayFunc | The gateway function to use. |
void
http
or https
.
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.
Parameter | Type | Description |
---|---|---|
getUrl | FetchGetUrlFunc | The function to use for fetching HTTP and HTTPS URIs. |
void