Skip to content

Instantly share code, notes, and snippets.

@dfkuro
Created October 12, 2021 03:53
Show Gist options
  • Save dfkuro/54c05bd23b29d37c399d778cd93c729b to your computer and use it in GitHub Desktop.
Save dfkuro/54c05bd23b29d37c399d778cd93c729b to your computer and use it in GitHub Desktop.
const fetchJson = (...args) =>
fetch(...args).then(response => {
if(!response.ok) {
throw new Error(`HTTP Error response: ${repsponse.status} ${response.statusText}`)
}
return response.json()
})
// Fetching JSON is simplified
const data = await fetchJson('https://blockchain.info/ticker')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment