Skip to main content

Module fetch

Module fetch 

Source
Expand description

HTTP requests made by the runner (gasm:fetch, TLS included): start one, then poll it each frame. Runners may deny requests (natively: --allow-net, optionally a host list; browsers: the page, and CORS). Probe [available] first.

let req = gasm::fetch::Request::get("https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=52&lon=21")
    .header("accept", "application/json")
    .send();
// later, each frame:
if req.state() == gasm::fetch::State::Done {
    let json = req.read_to_end();
}

Structs§

Request
A request to send. JSON-escapes what it’s given.
Response
A request in flight; dropping it cancels it.

Enums§

State

Functions§

available
Whether the runner has gasm:fetch.