Whether the end event of response in node.js must listen to the data event before emit can be emitted

  node.js, question
 var qs = require('querystring');
 require('http').createServer(function(req, res){
 var body = '';
 req.on('data', function(chunk){
 Body plus = chunk;
 req.on('end', function(){
 Log ('\ ngotname \ 033 [90m' plus qs.parse(body).name plus' \033[39m\n');
 var http = require('http'), qs = require('querystring');
 function send(theName){
 host: '',
 port: 3000,
 url: '/',
 method: 'POST'
 }, function(res){
 //res.on('data', function(){return ;  });
 res.on('end', function(){
 console.log('\n  \033[90m request complete!  \033[39m');
 process.stdout.write('\n  your name: ');
 }).end(qs.stringify({name: theName}));
 process.stdout.write('\n  your name: ');
 process.stdin.on('data', function(name){
 send(name.replace('\n', ''));

-From “The Great Node. JS” P98-P99

  • The callback function in the end event will not be executed if the event monitoring data in client.js is watched out.

  1. Hope to be able to help explain, thank you.

  2. By the way, how should I solve this problem so that I can solve it myself next time, thank you.

End is an event that occurs after reading data.