Last active
June 18, 2019 17:43
-
-
Save dariogabriel113/ddc638c3547292e3ab704a174e8bc450 to your computer and use it in GitHub Desktop.
Async/Await | https://hackernoon.com/6-reasons-why-javascripts-async-await-blows-promises-away-tutorial-c7ec10518dd9
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 makeRequest = async () => { | |
try { | |
const data = JSON.parse(await getJSON()) | |
console.log(data) | |
} catch (err) { | |
console.log(err) | |
} | |
} |
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 makeRequest = () => { | |
try { | |
getJSON() | |
.then(result => { | |
const data = JSON.parse(result) | |
console.log(data) | |
}) | |
} catch (err) { | |
console.log(err) | |
} | |
} |
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 makeRequest = async () => { | |
console.log(await getJSON()) | |
return "done" | |
} | |
makeRequest() |
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 makeRequest = () => | |
getJSON() | |
.then(data => { | |
console.log(data) | |
return "done" | |
}) | |
makeRequest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment