This article mainly introduces node. http. response. description of the write method. This document introduces http. response. write method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see
Method description:
Sends the response content to the requested client.
Before response. end (), response. write () can be executed multiple times.
Syntax:
The Code is as follows:
Response. write (chunk, [encoding])
Parameters:
A chunk is a buffer or string that indicates the content to be sent.
Encoding if the chunk is a string, you need to specify encoding to describe its encoding method. The default value is UTF-8.
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 );