Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // Async / Await pattern
  2. async function reportToMothership() {
  3. console.log(`Sending results to the mother ship...`);
  4.  
  5. let result: number;
  6.  
  7. try {
  8. result = await pAsyncApi();
  9. } catch (e) {
  10. console.error(`Failed to get results, cancelling message.`)
  11. throw e;
  12. }
  13.  
  14. try {
  15. const message = await pAsyncDoSomethingWithResult(result);
  16. console.log(`Message from the mothership: ${message}`);
  17. } catch (e) {
  18. console.error(`Failed to send results to the mothership.`)
  19. throw e;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement