Skip to main content

fetch

function fetch
allow-net
allow-read
Jump to headingfetch(
input:
URL
| Request
| string
,
init?: RequestInit,
): 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.

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 Jump to heading

Return Type Jump to heading

Promise<Response>
Jump to headingfetch(
input:
Request
| URL
| string
,
init?: RequestInit & { client: Deno.HttpClient; },
): Promise<Response>

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

Parameters Jump to heading

Jump to headinginput:
Request
| URL
| string
optional
Jump to headinginit: RequestInit & { client: Deno.HttpClient; }

Return Type Jump to heading

Promise<Response>
Back to top