Last active
August 29, 2015 14:24
-
-
Save burabure/cf3cdcdcf1c3addeffba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function requestHTML(url) { | |
return new Promise(function(resolve, reject){ | |
request(url, function (err, res, body) { | |
if (err) reject(err); | |
if (!body) reject(new Error('not an html')); | |
resolve(body); | |
}); | |
}); | |
}); | |
requestHTML('http://google.com') | |
.then(function(html){ | |
//hacer algo con el html? | |
console.log(html); | |
}) | |
.catch(function(err){ | |
//hacer algo con el err? | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment