Joined November 2014
·
Posted to
Scraping web pages using Node.js using request+promise
over 1 year
ago
If you use Request-Promise you get the same request+promise power with even less lines of code:
var rp = require('request-promise');
var url = "https://raw.github.com/mikeal/request/master/package.json";
rp({ url:url, json:true })
.then(function (data) {
console.log("%s@%s: %s", data.name, data.version, data.description);
})
.catch(function (reason) {
console.error("%s; %s", reason.error.message, reason.options.url);
console.log("%j", reason.response.statusCode);
});
I heard that
undefined
is immutable in EcmaScript 5. Turns out it actually means something else than I expected: https://gist.github.com/mzgol/5356300BTW, lodash.js uses solution 1.