Last active
April 25, 2017 00:52
-
-
Save casprwang/21635407535423f66ffc91c2ca703a18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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