Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda