host.fetch
Make HTTP requests from a client to local, private, or public services.
host.fetch sends HTTP requests from the selected client, including to local and private services accessible to that client.
Here, host is a selected RemoteHost; see host discovery to obtain one. The module overview covers permissions and shared errors.
host.fetch(input, options?)
Function: performs DNS, TCP/TLS, and HTTP requests from the selected client. It can reach local, private-network, and public services accessible to that client.
interface RemoteHost {
fetch(input: string | URL, options?: RemoteFetchOptions): Promise<Response>;
}| Parameter | Type | Required | Description |
|---|---|---|---|
input | string / URL | Yes | An absolute HTTP(S) URL; Request objects and URLs containing usernames or passwords are not accepted |
options.method | string | No | Defaults to GET; GET / HEAD cannot carry a body; CONNECT / TRACE / TRACK are unavailable |
options.headers | HeadersInit | No | Headers, a string-valued record, or an array of header pairs |
options.body | string / Uint8Array / ArrayBuffer / null | No | Buffered upload; FormData and upload streams are unsupported |
options.signal | AbortSignal | No | Cancels upload, waiting for a response, or reading its body |
options.redirect | RequestRedirect | No | follow (default, at most 20 redirects), manual, or error |
Return value: Promise<Response>; see Response for properties and body methods. Bodies stream on demand. HTTP 4xx / 5xx resolve normally; network failures reject. Consume or cancel the body.
Only listed request options are supported; other fields cause TypeError. There is no separate fetch permission switch. Cross-origin redirects remove sensitive headers such as Authorization and Cookie. Cookie Jars, caches, and application retries are not automatic. Code cannot override transport headers such as Host and Content-Length.
Active cancellation rejects with signal.reason and closes the remote response resource. It cannot undo an operation already delivered to the destination.
See remote.d.ts for type declarations.
