function fetch
Supported only in the v8 engine. Introduced in Max v9.2.0.
Fetches a resource over HTTP or HTTPS.
This is a compatibility subset of the WHATWG Fetch standard. Only http:// and https:// URLs are supported, and absolute URLs are required (there is no ambient page location). There is no browser CORS model, cache mode, persistent cookie store, document.cookie, public-suffix enforcement, or SameSite enforcement. There is intentionally no global File class because Max already provides a different File object.
The promise resolves once status and headers are available; the body streams afterward through Response.body or the buffered body helpers. Requires an absolute http:// or https:// URL.
gzip / deflate responses are decoded transparently; when that happens the exposed headers omit content-encoding and content-length.
export declare function fetch(
input: string | Request,
init?: RequestInit,
): Promise<Response>;
| Name | Type | Description |
|---|---|---|
| input | string | Request | an absolute URL string or a Request. |
| optional init | RequestInit | request options. |
| Return Value | Promise<Response> | a promise for the Response. |
Example
(async () => {
const response = await fetch("https://example.com/");
post(response.status, response.ok, "\n");
post(await response.text(), "\n");
})();