Tengo el siguiente rizo:
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"}]}' En NodeJS, recibo el req.body como un objeto:
{ '{"data":[{"id":"12345"}]}' }pero debería recibir como un JSON como en el rizo:
{"data":[{"id":"12345"}]}Este es mi controlador:
router.post('/updated', express.json(), function (req, res) { logger.info(req.body) // output as object, and It should be a JSON }); ¿Alguna idea para eliminar el { adicional o recibir un JSON como en el rizo?
Intente cambiar Content-Type: application/x-www-form-urlencoded a Content-Type: application/json en su comando curl