Last active
July 31, 2017 08:57
-
-
Save mtinra/a592901df44137dc7fc8e4f3bb2faa29 to your computer and use it in GitHub Desktop.
Async Await sample with fetch function
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
// Fetch is return promise | |
// function fetchAlmbums() { | |
// fetch('http://rallycoding.herokuapp.com/api/music_albums') | |
// .then(res => res.json()) | |
// .then(json => console.log(json)); | |
// } | |
// fetchAlmbums(); | |
const fetchAlmbums = async () => { | |
const res = await fetch('http://rallycoding.herokuapp.com/api/music_albums'); | |
const json = await res.json(); | |
console.log(json); | |
}; | |
fetchAlmbums(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment