Last active
December 4, 2015 17:29
-
-
Save relaxedtomato/cb36d40c485c61fbb8f8 to your computer and use it in GitHub Desktop.
Error Handling
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
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