This article mainly introduces node. http. response. end method usage instructions. This article introduces http. response. end method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
End the response and tell the client that all messages have been sent. When all the content to be returned is sent, the function must be called once.
If you do not call this function, the client will always be in the waiting state.
Syntax:
The Code is as follows:
Response. end ([data], [encoding])
Receiving parameters:
The character to be output after data end () is executed. If the value of data is specified, it means the response is executed. after end (), a response is executed. write (data, encoding );
Character encoding of data corresponding to encoding
Example:
The Code is as follows:
Var http = require ('http ');
Http. createServer (function (req, res ){
Res. writeHead (200, {'content-type': 'text/html '});
Res. write ('node. js ');
Res. end ('
Hello World
');
}). Listen (3000 );