Instructions for the http.response.end method in node.js
- 2020-05-05 10:52:32
- OfStack
method description:
End the response to tell the client that all messages have been sent. The function must be called once all that is returned has been sent.
How not to call this function, the client will always be in a waiting state.
syntax:
response.end([data], [encoding])
receive parameters:
data
When end() is finished, if the value of data is specified, then response.write (data, encoding) will be followed by response.write (data, encoding).encoding
corresponds to data character codeexample:
var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);