You should use the URL, not the domain name http.get, unless you specify optionsas an object:
optionsmay be an object or a string. If optionsis a string, it is automatically parsed using url.parse().
:
var http = require('http');
http.get('http://www.google.com/', function(res) {
console.log(res.statusCode);
});
var http = require('http');
http.get({host:'www.google.com'}, function(res) {
console.log(res.statusCode);
});
.
. , , , host , localhost, , . :
var http = require('http');
http.get({}, function(res) {
console.log(res.statusCode);
});