Dev Helpers
← Back

Build a request with a JSON body

Build a request with a JSON body using Node.js.

Open this example in the interactive library

Source code

import { Blob } from "node:buffer";
console.log(
  await new Request("https://example.org/", {
    method: "POST",
    body: JSON.stringify({ n: 3 }),
  }).json(),
);

Sample output

{ n: 3 }