Skip to content

Instantly share code, notes, and snippets.

@jjsub
Created April 24, 2018 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsub/ebb4ff02bcd8b823b8fb17c041ae058e to your computer and use it in GitHub Desktop.
Save jjsub/ebb4ff02bcd8b823b8fb17c041ae058e to your computer and use it in GitHub Desktop.
// regular Promise()
function fetchAlbums() {
fetch('https://http://rallycoding.herokuapp.com/api/music_albums')
.then(res => res.json())
.then(json => console.log(json));
}
//async
async function fetchAlbums() {
const res = await fetch('http://rallycoding.herokuapp.com/api/music_albums');
const json = await res.json();
console.log(json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment