Dev HelpersOpen library
← Back

Create a request

Create a request. A self-contained example using the JavaScript runtime.

Open this example in the interactive library

Source code

const request = new Request("https://example.com/items", {
  method: "POST",
  body: JSON.stringify({ id: 7 }),
  headers: { "Content-Type": "application/json" },
});
console.log(request.method, await request.json());

Sample output

POST { id: 7 }