Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Created December 11, 2018 23:24
Show Gist options
  • Select an option

  • Save chrisdel101/57d7db61bcf9e7f9150c54a6efd6f119 to your computer and use it in GitHub Desktop.

Select an option

Save chrisdel101/57d7db61bcf9e7f9150c54a6efd6f119 to your computer and use it in GitHub Desktop.
// get array of ids
function getTopIDs(url) {
return fetch(url).then(blob => blob.json()).then(json => json)
}
// returns a promise resolves to an object
function getStory(id) {
let url = `https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
return fetch(url).then(blob => blob.json()).then(json => json)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment