Node.js HTTP: request 'end' event is never called

Viewed 6551

I have a client that is sending data chunks to my node.js server.

I want to listen on the "end" event and retrieve the accumulated request body.

Here is my code:

app.post('/users', function(req, res){

  req.on('end', function() { // WHY IS THIS NEVER FIRED?
    console.log(req.body);

    res.send({
      "status": "ok"
    });

  });

});

The problem is that the 'end' event is never fired.

Anyone knows why?

Also, if I do in this way, will the req.body be the accumulated body of all the body chunks?

2 Answers
Related