Skip to content

Instantly share code, notes, and snippets.

@mtinra
Last active July 31, 2017 08:57
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