To get data out of a Node.js http get request, we listen for the data event.
For instance, we write
require("http").get("http://httpbin.org/ip", (res) => {
res.setEncoding("utf8");
res.on("data", (body) => {
console.log(body);
});
});
to call res.on to listebn to the data event.
We get the response body from the body parameter in the callback.