function fetchWithTimeout
fetchWithTimeout(
url: string,
timeoutMs?: number
): Promise<Response>

Fetches a user-supplied URL, following up to five redirects, each of which must resolve to a public address too. timeoutMs bounds each hop, body included. The caller must read or cancel the body, or its connection stays open.

Parameters

url: string
optional
timeoutMs: number = 5000

Return Type

Promise<Response>

Throws

TypeError

When a hop isn't http(s), there are too many redirects, or the request fails.

Error

When a hop's host is private or can't be resolved.

Usage

import { fetchWithTimeout } from "api/remote/fetch.ts";