Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Promise Pattern
- function reportToMotherShip() {
- console.log(`Sending results to the mothership...`);
- return pAsyncApi()
- .catch(e => {
- console.error(`Failed to retrieve results, cancelling message.`);
- return Promise.reject(e);
- })
- .then(result =>
- pAsyncDoSomethingWithResult(result)
- .catch((error) => {
- console.error(`Failed to send results to the mothership.`)
- return Promise.reject(error)
- })
- )
- .then(message => console.log(`Message from the mothership: ${message}`))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement