Skip to content

Instantly share code, notes, and snippets.

@sahajamit
Forked from Gaafar/catch-promise.js
Created August 18, 2017 02:30
Show Gist options
  • Save sahajamit/4f1d771a63958d55c8e9aca05020a405 to your computer and use it in GitHub Desktop.
Save sahajamit/4f1d771a63958d55c8e9aca05020a405 to your computer and use it in GitHub Desktop.
const makeRequest = () => {
try {
getJSON()
.then(result => {
// this parse may fail
const data = JSON.parse(result)
console.log(data)
})
// uncomment this block to handle asynchronous errors
// .catch((err) => {
// console.log(err)
// })
} catch (err) {
console.log(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment