Skip to content

Instantly share code, notes, and snippets.

@mtinra
Last active July 31, 2017 08:57
Show Gist options
  • Save mtinra/a592901df44137dc7fc8e4f3bb2faa29 to your computer and use it in GitHub Desktop.
Save mtinra/a592901df44137dc7fc8e4f3bb2faa29 to your computer and use it in GitHub Desktop.
Async Await sample with fetch function
// 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