[Node.js] Send a JSON POST request with Axios

Created on November 30, 2026

You can use axios.post() to send a POST request. Pass the destination URL as the first argument and a JavaScript object as the second. Axios sends the object as JSON.

Install Axios in your Node.js project before running this example.

npm install axios
const axios = require("axios");

async function main() {
  const response = await axios.post("https://example.com/users", {
    name: "Tom",
  });
  console.log(response.data);
}

main().catch((error) => {
  console.error(error.message);
  process.exitCode = 1;
});

Replace the example URL with your endpoint. The script prints the response body from response.data.

Reference

Node.js JavaScript