interface
FetchOptionsOptions for fetch.
method?: string"GET", "POST").headers?: Record<string, string>body?: stringcontent-type).timeoutMs?: number@s2script/sdk/http
async HTTP.
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(): 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 only on a network error or timeout.
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);