Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement