Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. await doAllCats();
  2. await doAllDogs();
  3. console.log("Finished processing Cats and Dogs ")
  4.  
  5. function doAllCats() {
  6. let promiseArray = [];
  7. for(let cat of cats) {
  8. promiseArray.push(doOneCat(cat);
  9. }
  10. return Promise.all(promiseArray);
  11. }
  12. function doOneCat(cat) {
  13. let promise = doSomeAsyncStuffWithACat(cat);
  14. p.catch() {
  15. console.error("there was a problem with "+cat+" but processing should continue as normal for the other cats and dogs");
  16. }
  17. return p;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement