Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- await doAllCats();
- await doAllDogs();
- console.log("Finished processing Cats and Dogs ")
- function doAllCats() {
- let promiseArray = [];
- for(let cat of cats) {
- promiseArray.push(doOneCat(cat);
- }
- return Promise.all(promiseArray);
- }
- function doOneCat(cat) {
- let promise = doSomeAsyncStuffWithACat(cat);
- p.catch() {
- console.error("there was a problem with "+cat+" but processing should continue as normal for the other cats and dogs");
- }
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement