Skip to content

Instantly share code, notes, and snippets.

@johnstew
Created July 17, 2017 12:34
Show Gist options
  • Select an option

  • Save johnstew/5800b09b9e8acaf1f6c9dfbaf114976b to your computer and use it in GitHub Desktop.

Select an option

Save johnstew/5800b09b9e8acaf1f6c9dfbaf114976b to your computer and use it in GitHub Desktop.

Revisions

  1. John Stewart created this gist Jul 17, 2017.
    19 changes: 19 additions & 0 deletions async-await-5.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    // Variable Assignment
    const getData = async function () {
    try {
    const data = await fakeAsyncCall();
    console.log(data); // foo data
    } catch (error) {
    console.error(`Uh oh: ${error}`);
    }
    };

    // IIFE
    (async function() {
    try {
    const data = await fakeAsyncCall();
    console.log(data); // foo data
    } catch (error) {
    console.error(`Uh oh: ${error}`);
    }
    })();