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

138
Vistas
req.on is not getting trigger while using type application/json
  req.on("data", (chunk) => {
  console.log("daataa second",body)
  body += chunk.toString();
});

When i am posting the data from the postman as the type then it successfully processing the data but when i am passing the data in json format then it is not triggering this method.

If i use json middleware, then none of the data or end event on request object is fired but I removed the json parser from your code, and then the events started firing

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

0

JSON parser middleware reads the entire request stream containing a JSON payload, parses it and creates a JavaScript object for you. For example in Express, express.json returns middleware that reads and saves JSON payloads as the req.body object if the request contains JSON data

JSON middleware needs to read the entire request stream in order to parse its content using JSON.parse(string), and so will not call next to invoke further steps in request routing before the stream has been read and parsed. Hence listeners added later in the route to monitor data and/or end events will not fire because the data has already been read, and the end event has already fired.

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