Skip to content

Instantly share code, notes, and snippets.

@SastraNababan
Created November 1, 2017 04:56
Show Gist options
  • Save SastraNababan/abc17da38ba26d57a66987194267eda9 to your computer and use it in GitHub Desktop.
Save SastraNababan/abc17da38ba26d57a66987194267eda9 to your computer and use it in GitHub Desktop.
fetch async await error handling
async function fetchWithAsyncAwait (id) {
try {
let response = await fetch(endpoint + id)
response = await response.json()
console.log(response)
} catch (error) {
console.log('opps' + error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment