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

95
Views
Form data objectsent from frontend read as undefined in backend

Technologies: [ {Frontend: 'Vue-js 2'}, {Backend: 'Node-js / Express / SQL'} ] I need to send a comment comming from a form-data with 3 entries (content / userID / PostId)

Front-side I have all the values setup. Then in my backend when I log req.body I got an empty Object...

Why my form data is empty ? or is my backend not able to read it ?

Function from my front :

 newComment(idPost) {
  const comment = new FormData();
  comment.append('content', this.comment);
  comment.append('userId', this.user.userId);
  comment.append('postId', idPost);

  for (let pairs of comment.entries()) {
    console.log(pairs);
  }
  const headers = {
    'Content-type': 'application/json',
    Authorization: 'Bearer ' + this.user.token,
  };
  axios
    .post(`${url}comment`, comment, { headers }).then(etc....)

In my logs : form data entries log

Function from my back :

  exports.createComment = (req, res, next) => {
  console.log('new comment............')
  console.log(req.body);
  const content = req.body.content;
  const userId = req.body.userId;
  const postId = req.body.postId;
  db.query(
    `INSERT INTO comments (content, userId, postId) VALUES ('${content}', '${userId}', '${postId}')`,
    (err, result, fields) => {...}

In my logs : backend req.body logs

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!