Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!