Where is the documentation on res.on('end'
Where is the documentation on res.on('end'
Just cant find it! looking for documentation on the following on error, data, and end
return new Promise((resolve, reject) =>
https.get(setUrl(substr), (res) =>
let data = ''
res.on('data', (d) =>
data += d
);
res.on('end', () => resolve(data));
).on('error', reject);
);
https.get()
https
@TedHopp -
https
is the https module built into node.js.– jfriend00
Sep 2 at 18:24
https
1 Answer
1
In the doc for https.get()
, it says to go look at the doc for http.get()
for the callback parameters.
https.get()
http.get()
There it says:
The callback is invoked with a single argument that is an instance of http.IncomingMessage
.
http.IncomingMessage
And, if you then go look at the doc for http.IncomingMessage
, you find that:
http.IncomingMessage
It implements the Readable Stream interface, as well as the following additional events, methods, and properties.
In that doc, you will find a description of the data
and end
events.
data
end
The https.get()
itself returns an http.ClientRequest
object and in the doc for http.request()
which https.get()
is derived from, it explains:
https.get()
http.ClientRequest
http.request()
https.get()
If any error is encountered during the request (be that with DNS resolution, TCP level errors, or actual HTTP parse errors) an 'error' event is emitted on the returned request object. As with all 'error' events, if no listeners are registered the error will be thrown.
Yes, it is work to follow all this. This is one of the aspects of object oriented design with lots of derived and common objects. You have to find the object being used or perhaps even the base object and then go look in its doc for find out how to use it.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It's probably part of the documentation for
https.get()
. You don't tell us what kind of objecthttps
is, so it's hard to say more without a lot of guessing.– Ted Hopp
Sep 2 at 6:10