Answer the question
In order to leave comments, you need to log in
Asynchronous node.js request processing (express)?
Dear experts, please help with the following problem. There is a simple code on node.js (express)
01 var poster = function (req, out)
02 {
03 var body = '';
04 console.log(1);
05
06 req.on('readable', function(){
07 console(2);
08 body += req.read();
09 }).
10 on('end', function(){});
11 console(3);
12 out.end('end');
13 }
14
15 app.post('/publish', poster);
$http.post('/publish', JSON.stringify({user: 23, mesg: "Message"})).success(function(answer){
alert(answer);
});
Answer the question
In order to leave comments, you need to log in
and what kind of event is this, readable? I thought that you need to subscribe to data and read the request body in pieces (in fact, this is what you get).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question