namespace

fetch

function fetch(
input: string | URL | Request,
): Promise<Response>;

Send an HTTP(S) request.

@param input

URL string, URL, or Request object

@param init

Options for the request

@returns

A promise that resolves to the Response

namespace fetch

Bun's extensions of the fetch API

  • function preconnect(
    url: string | URL,
    options?: { dns: boolean; http: boolean; https: boolean; tcp: boolean }
    ): void;

    Resolve a URL's DNS and establish a TCP connection before a request is made, to speed up the eventual fetch.

    Not part of the Fetch API specification.

    @param url

    The URL to preconnect to

    @param options

    Which stages of the connection to set up