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

135
Views
request.body returning empty object

My request.body is returning an empty object in express 4.17.1. It works fine on postman, but when I try consuming it at the frontend using javascript I get an empty object, even when I console.log it

Below is my code:

/////Express backend

const express = require('express');
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(cors());

////React frontend
 const myData = {   
  _id: "616a4663c3086a539a8c3dcc",
  type: "describe_yourself",
  name: "white"
 }


React.useEffect( () => {
    fetch('http://localhost:9000/test', {
      method: 'POST',
      headers: {
          'Content-type': 'application/json'
        },
      body: JSON.stringify(myData)
    }).then(response => response.json())
    .then(data => console.log(data))

}, [])

I am not using body-parser because it is deprecated. I will really appreciate anyone that can help me. thanks in advance

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!