Skip to content

Instantly share code, notes, and snippets.

@relaxedtomato
Last active December 4, 2015 17:29
Show Gist options
  • Save relaxedtomato/cb36d40c485c61fbb8f8 to your computer and use it in GitHub Desktop.
Save relaxedtomato/cb36d40c485c61fbb8f8 to your computer and use it in GitHub Desktop.
Error Handling
rp(options)
.then(function ($) {
var titles = $('div > div > div.title.align-top > a');
var urls = titles.map(function (index, div) { // collecting urls
return $(div).attr('href')
})
var requests = urls.map(function (index, url) { // creating promises from requests on urls
return rp(root + url) // .then(turnIntoInstances);
})
debugger
// once all promises are resolved
q.all(requests).then(function (results) { // q.all == single promise to represent all url query promises
console.log('done' + results.length)
}).catch(function(err){ //adding error handling here as well
console.error('something went wrong', err)
});
})
.catch(function (err) {
console.log(err)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment