Last active
June 22, 2020 17:26
-
-
Save treyhuffine/4fdf8a0baf9e1de209b0eb96031780d4 to your computer and use it in GitHub Desktop.
This file contains 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
const apiRequest = () => { | |
return new Promise((resove) => { | |
// do some async things for an unknown amount of time... | |
return resolve({ answer: 42 }); | |
}) | |
} | |
const run = () => { | |
apiRequest.then((response) => { | |
console.log(response); | |
}) | |
} | |
// Since it's all just promises, you can mix and match with async/await | |
const runAsAsyncAwait = async () => { | |
const response = await apiRequest(); | |
console.log(response); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment