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

137
Vistas
nodejs request body as json

I have the following curl:

curl 'http://localhost:9008/updated' \ 
  -H 'Connection: keep-alive' \
  -H 'Accept: application/json, text/plain, /' \ 
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36' \ 
  -H 'Content-Type: application/x-www-form-urlencoded' \ 
  -H 'Accept-Language: es-ES,es;q=0.9' \ 
  -data-raw '{"data":[{"id":"12345"}]}'

In NodeJS, I receive the req.body as an object:

{ '{"data":[{"id":"12345"}]}' }

but I should receive as a JSON like in the curl:

{"data":[{"id":"12345"}]}

This is my handler:

router.post('/updated', express.json(), function (req, res) {
   logger.info(req.body) // output as object, and It should be a JSON
});

Any ideas to remove the extra { or receive a JSON like in the curl?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try changing Content-Type: application/x-www-form-urlencoded to Content-Type: application/json in your curl command

about 4 years ago · Juan Pablo Isaza Denunciar
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