Ответ 1
Посмотрите пример здесь в документе node.js.
Метод http.get
является удобным методом, он обрабатывает множество базовых материалов для запроса GET, который обычно не имеет к нему никакого тела. Ниже приведен пример того, как сделать простой HTTP-запрос GET.
var http = require("http");
var options = {
host: 'www.google.com'
};
http.get(options, function (http_res) {
// initialize the container for our data
var data = "";
// this event fires many times, each time collecting another piece of the response
http_res.on("data", function (chunk) {
// append this chunk to our growing `data` var
data += chunk;
});
// this event fires *one* time, after all the `data` events/chunks have been gathered
http_res.on("end", function () {
// you can use res.send instead of console.log to output via express
console.log(data);
});
});