httpRequest
Make a synchronous text HTTP request.
js
httpRequest(url, method = "GET", headers?, body?)Arguments
| Argument | Type | Meaning |
|---|---|---|
url | string | HTTP(S) URL. |
method | string | Default GET. |
headers | object | Optional string header values. |
body | string | Optional body; serialize JSON yourself. |
Returns
Response text, or null on failure; cancellation may throw.
Example
js
const text = httpRequest("https://example.com", "GET");
if (text === null) throw new Error("Request failed");
console.log(text);Notes
Wait deadline 30 seconds. Does not expose status or response headers; prefer fetch when you need them.