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 }