Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda