Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // Promise Pattern
  2. function reportToMotherShip() {
  3. console.log(`Sending results to the mothership...`);
  4. return pAsyncApi()
  5. .catch(e => {
  6. console.error(`Failed to retrieve results, cancelling message.`);
  7. return Promise.reject(e);
  8. })
  9. .then(result =>
  10. pAsyncDoSomethingWithResult(result)
  11. .catch((error) => {
  12. console.error(`Failed to send results to the mothership.`)
  13. return Promise.reject(error)
  14. })
  15. )
  16. .then(message => console.log(`Message from the mothership: ${message}`))
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement