Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Async / Await pattern
- async function reportToMothership() {
- console.log(`Sending results to the mother ship...`);
- let result: number;
- try {
- result = await pAsyncApi();
- } catch (e) {
- console.error(`Failed to get results, cancelling message.`)
- throw e;
- }
- try {
- const message = await pAsyncDoSomethingWithResult(result);
- console.log(`Message from the mothership: ${message}`);
- } catch (e) {
- console.error(`Failed to send results to the mothership.`)
- throw e;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement