Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // const fetch = async () => {
  2. // return new Promise ((resolve, reject) => {
  3. // // reject('Oooops, somethign went wrong')
  4. // resolve(`{"text": "some text"}`)
  5. // })
  6. // }
  7.  
  8. const fetch = () => {
  9. return new Promise((resolve, reject) => {
  10. resolve('a resolve')
  11. reject('a rejection')
  12. })
  13. }
  14.  
  15. const foo = () => {
  16. fetch()
  17. .then(result => {
  18. console.log(result)
  19. })
  20. .catch(error => { console.log(error) })
  21. }
  22.  
  23. // const foo = () => {
  24. // try {
  25. // fetch()
  26. // .then(result => {
  27. // console.log(result)
  28. // // .catch(error => console.log(error))
  29. // })
  30. // .catch(error=> console.log(error))
  31. // }
  32. // catch (error) {
  33. // console.log(error)
  34. // }
  35. // }
  36.  
  37. foo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement