FetchOptionsOptions for fetch.
method?: string"GET", "POST").headers?: Record<string, string>body?: stringcontent-type).timeoutMs?: number@s2script/sdk/http
Off-thread fetch. Admission rejects with AsyncQueueFull / AsyncPayloadTooLarge; oversized responses reject with HttpResponseTooLarge.
import { FetchOptions } from "@s2script/sdk/http";Author-time types ship in the npm package; the engine injects the runtime at plugin load.
Add @s2script/sdk to your plugin's dependencies.
Generated from the shipped type definitions.
FetchOptionsOptions for fetch.
method?: string"GET", "POST").headers?: Record<string, string>body?: stringcontent-type).timeoutMs?: numberResponseThe response from a fetch call — a copied snapshot (no live socket).
readonly status: number200, 404).readonly ok: booleanreadonly statusText: string"Not Found").readonly headers: Record<string, string>text(): stringjson<T = unknown>(): TT (throws on invalid JSON).fetch(url: string, options?: FetchOptions): Promise<Response>Perform an HTTP request off the game thread.
http(s):// URL.Returns — Resolves for ANY HTTP response — a 4xx/5xx resolves with ok=false, it does not reject.
Throws — Rejects on a network error or timeout, or with AsyncQueueFull / AsyncPayloadTooLarge
before acceptance. HttpResponseTooLarge when the retained UTF-8 body plus headers exceed the
configured limit.
import { fetch } from "@s2script/sdk/http";
const r = await fetch("https://httpbin.org/get", { timeoutMs: 15000 });
if (r.ok) console.log(r.json<{ url: string }>().url);