Skip to content

Instantly share code, notes, and snippets.

@johnstew
Created July 17, 2017 12:35
Show Gist options
  • Save johnstew/39f2ed427b19c43b07ac86dea4fb74fc to your computer and use it in GitHub Desktop.
Save johnstew/39f2ed427b19c43b07ac86dea4fb74fc to your computer and use it in GitHub Desktop.
// Variable assignment
const getData = async () => {
try {
const data = await fakeAsyncCall();
console.log(data); // foo data
} catch (error) {
console.error(`Uh oh: ${error}`);
}
}
// IIFE
(async () => {
try {
const data = await fakeAsyncCall();
console.log(data); // foo data
} catch (error) {
console.error(`Uh oh: ${error}`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment