fetch

Fetch a resource from the network. It returns a Promise that resolves to the Response to that Request, whether it is successful or not.

const response = await fetch("http://my.json.host/data.json");
console.log(response.status);  // e.g. 200
console.log(response.statusText); // e.g. "OK"
const jsonData = await response.json();
function fetch(input: URL | Request | string, init?: RequestInit): Promise<Response>;
function fetch(input: Request | URL | string, init?: RequestInit & {
client: Deno.HttpClient;
}
): Promise<Response>;
§
fetch(input: URL | Request | string, init?: RequestInit): Promise<Response>
[src]

Fetch a resource from the network. It returns a Promise that resolves to the Response to that Request, whether it is successful or not.

const response = await fetch("http://my.json.host/data.json");
console.log(response.status);  // e.g. 200
console.log(response.statusText); // e.g. "OK"
const jsonData = await response.json();

§Parameters

§
input: URL | Request | string
[src]
§
init?: RequestInit optional
[src]

§Return Type

§
fetch(input: Request | URL | string, init?: RequestInit & {
client: Deno.HttpClient;
}
): Promise<Response>
[src]

UNSTABLE: New API, yet to be vetted.

The Fetch API which also supports setting a Deno.HttpClient which provides a way to connect via proxies and use custom TLS certificates.

§Parameters

§
input: Request | URL | string
[src]
§
init?: RequestInit & {
client: Deno.HttpClient;
}
optional
[src]

§Return Type