var req = require('request');
var Q = require('q');
function getPage(url) {
var deferred = Q.defer();
req(url, function(err, r, body) {
if (error || r.statusCode != 200) {
deferred.reject(new Error(err));
} else {
deferred.resolve(body);
}
});
return deferred.promise;
}
getPage('http://google.com').then(function(body) {
console.log(body);
});