http
Make HTTP requests with the Rust backend.
Interfaces
ClientOptions
Options to configure the Rust client used to make fetch requests
Properties
Property | Type | Description | Defined in |
---|---|---|---|
connectTimeout? | number | Timeout in milliseconds | |
maxRedirections? | number | Defines the maximum number of redirects the client should follow. If set to 0, no redirects will be followed. | |
proxy? | Proxy | Configuration of a proxy that a Client should pass requests to. |
Proxy
Configuration of a proxy that a Client should pass requests to.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
all? | string | ProxyConfig | Proxy all traffic to the passed URL. | |
http? | string | ProxyConfig | Proxy all HTTP traffic to the passed URL. | |
https? | string | ProxyConfig | Proxy all HTTPS traffic to the passed URL. |
ProxyConfig
Properties
Functions
fetch()
function fetch(input, init?): Promise<Response>
Fetch a resource from the network. It returns a Promise
that resolves to the
Response
to that Request
, whether it is successful or not.
Parameters
Parameter | Type |
---|---|
input | string | URL | Request |
init ? | RequestInit & ClientOptions |
Returns
Example
const response = await fetch("http://my.json.host/data.json");console.log(response.status); // e.g. 200console.log(response.statusText); // e.g. "OK"const jsonData = await response.json();