A
A
AlinaCat2019-02-24 00:40:43
Node.js
AlinaCat, 2019-02-24 00:40:43

Res.end - what's the point?

I can't understand what is the essence of the res.end() method.
What is he doing?
Google didn't turn up anything sane.
I'm talking about res object in CreateServer

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VoidVolker, 2019-02-24
@AlinaCat

Class: http.ServerResponse
Added in: v0.1.17
This object is created internally by an HTTP server — not by the user. It is passed as the second parameter to the 'request' event.
The response inherits from Stream , and additionally implements the following:
Stream.end(): https://nodejs.org/api/stream.html#stream_writable...
https://js-node.ru/site/article?id=41#stream_writa...
Calling the writable.end() method signals that there is no more data to write to the stream opened for writing. The optional arguments chunk and encoding allow the last extra chunk of data to be written just before the stream closes. When an optional callback function is provided, it is added as a listener for the 'finish' event.
Calling the stream.write() method after calling stream.end() will result in an error.

And what is the difficulty in simply reading the documentation?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question