Skip to content

Instantly share code, notes, and snippets.

@casprwang
Last active April 25, 2017 00:52
Show Gist options
  • Save casprwang/21635407535423f66ffc91c2ca703a18 to your computer and use it in GitHub Desktop.
Save casprwang/21635407535423f66ffc91c2ca703a18 to your computer and use it in GitHub Desktop.
// const fetch = async () => {
// return new Promise ((resolve, reject) => {
// // reject('Oooops, somethign went wrong')
// resolve(`{"text": "some text"}`)
// })
// }
const fetch = () => {
return new Promise((resolve, reject) => {
resolve('a resolve')
reject('a rejection')
})
}
const foo = () => {
fetch()
.then(result => {
console.log(result)
})
.catch(error => { console.log(error) })
}
// const foo = () => {
// try {
// fetch()
// .then(result => {
// console.log(result)
// // .catch(error => console.log(error))
// })
// .catch(error=> console.log(error))
// }
// catch (error) {
// console.log(error)
// }
// }
foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment