Created
July 23, 2017 02:15
-
-
Save johndaley-me/888b09046693186fc5e96749449a3e60 to your computer and use it in GitHub Desktop.
Extra Promise and await
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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