Skip to content

Instantly share code, notes, and snippets.

@johndaley-me
Created July 23, 2017 02:15
Show Gist options
  • Save johndaley-me/888b09046693186fc5e96749449a3e60 to your computer and use it in GitHub Desktop.
Save johndaley-me/888b09046693186fc5e96749449a3e60 to your computer and use it in GitHub Desktop.
Extra Promise and await
// these two functions are conceptually equivalent
async function findFoo1() {
console.log('finding foo 1');
const rval = await findFooById(1);
console.log('I have foo 1');
return rval;
}
function findFoo1() {
console.log('finding foo 1');
return findFooById(1).then((foo1) => {
console.log('I have foo 1');
return foo1;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment