Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Axios post method is sending a object with my data as the key and empty value rather than the whole data object itself

I made the frontend first and now I'm want to make the backend so I can connect to a database.

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));

app.get("/", function (req, res) {
  res.send("hello");
});
app.post("/", function (req, res) {
  console.log(req.body);
});
app.listen(3001, function () {
  console.log("listening on 3001");
});

And this is the request I'm making on my React frontend.

axios.post("http://localhost:3001/", JSON.stringify(note));

note is an object like {title: "",content: ""} the empty string gets filled out with submission data.

When I make the post request this is what gets logged in the console

{ '{"title":"test","content":"one"}': '' }

I had to use JSON.stringify() to show what's being passed through but without it, my output is {}

When my object is posted it becomes the key of an object with empty values.

What I want to do is simply send the whole object like so

axios.post("http://localhost:3001/", note); 

so that in the backend I can tap into the values by doing req.body.title and req.body.content.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!