Skip to content

Instantly share code, notes, and snippets.

@demiters
Last active December 13, 2017 18:31
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 demiters/d4ddef7078920eab5eeec987fd0b9c5e to your computer and use it in GitHub Desktop.
Save demiters/d4ddef7078920eab5eeec987fd0b9c5e to your computer and use it in GitHub Desktop.
Shortest getJSON implementation with fetch. Call: `const data = await getJSON('https://api.com')`
const getJSON = async (url) => await fetch(url)
.then(res => res.json())
.catch(err => console.error(`${err.message} (${url})`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment