Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Promise = require('bluebird');
- var tests = [
- "hell",
- "hell",
- "hell",
- "heaven",
- "hell"
- ];
- var networkCall = function(test) {
- if (test == "heaven") {
- console.log('failure');
- return Promise.reject();
- } else {
- console.log('great success');
- return Promise.resolve();
- }
- };
- return Promise.map(
- tests,
- function(test) {
- return networkCall(test)
- .catch(function(){
- console.log('forgiveness is key if you wish to continue with the rest');
- return Promise.resolve();
- })
- }
- )
- .then(function(){
- console.log('then2', arguments);
- return Promise.resolve();
- })
- .catch(function(){
- console.log('catch2', arguments);
- });
Add Comment
Please, Sign In to add comment