matthewfl/node-host — Issue #20: can't make http.get to work
Author: rafaelcastrocouto
Created: 2012-03-01 12:20:00+00:00
State: open

Am i doing something wrong?

var http = require('http'),
url = require('url');
exports.app = function(req, res){
var options = {
host: 'www.google.com',
port: 80,
path: '/'
};
http.get(options, function(r) {
var data = '';
r.on('data', function(chunk) {
data += chunk;
});
r.on('end', function() {
res.end(data);
});
}).on('error', function(e) {
res.end("Got error: " + e.message);
});

}