let req = new Request("https://httpbin.org/post");
req.method = "post";
req.headers = {
"x-something": "foo bar",
"Content-Type": "application/json"
};
req.body = JSON.stringify({
foo: "bar",
qux: 42
});
// use loadJSON because the API answers with JSON
let res = await req.loadJSON();
log(JSON.stringify(res, null, 2));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter