Guest User

Untitled

a guest
Jul 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. var Promise = require('bluebird');
  2.  
  3. var tests = [
  4. "hell",
  5. "hell",
  6. "hell",
  7. "heaven",
  8. "hell"
  9. ];
  10.  
  11. var networkCall = function(test) {
  12. if (test == "heaven") {
  13. console.log('failure');
  14. return Promise.reject();
  15. } else {
  16. console.log('great success');
  17. return Promise.resolve();
  18. }
  19. };
  20.  
  21. return Promise.map(
  22. tests,
  23. function(test) {
  24. return networkCall(test)
  25. .catch(function(){
  26. console.log('forgiveness is key if you wish to continue with the rest');
  27. return Promise.resolve();
  28. })
  29. }
  30. )
  31. .then(function(){
  32. console.log('then2', arguments);
  33. return Promise.resolve();
  34. })
  35. .catch(function(){
  36. console.log('catch2', arguments);
  37. });
Add Comment
Please, Sign In to add comment