Skip to main content

HTTP Client

The Wing standard library comes with HTTP support.

In this example we’ll use it to issue a simple HTTP request.

main.w
bring http;
bring cloud;

struct Pokemon {
id: str;
name: str;
order: num;
weight: num;
}

new cloud.Function(inflight () => {
let x = http.get("https://pokeapi.co/api/v2/pokemon/ditto");

// response status
log(x.status);

// Cast response back into struct
let ditto = Pokemon.fromJson(x.body);
log(ditto.name);

});
Wing console output
# Run locally with wing console
No directory found