Skip to main content
fetch - Fetch - Web documentation
function fetch
allow-net
allow-read
fetch(
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. ```ts 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
optional
init: RequestInit

Return Type

Promise<Response>
fetch(
input:
Request
| URL
| string
,
init?: RequestInit & { client: Deno.HttpClient; },
): Promise<Response>
The [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/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
optional
init: RequestInit & { client: Deno.HttpClient; }

Return Type

Promise<Response>