Advertisement
Guest User

async await

a guest
Feb 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const futureFunc = () => {
  2.     return new Promise ((resolve, reject) => {
  3.         setTimeout(() => {
  4.             resolve('This is Dwight, from the future')
  5.         }, 1000)
  6.     })
  7. }
  8.  
  9.  
  10. const otherFunc = async () => {
  11.     let messageFromTheFuture = await futureFunc()
  12.  
  13.     return `${messageFromTheFuture}!!!!`
  14. }
  15.  
  16. const value = otherFunc()
  17.  
  18. value.then((val) => console.log(val))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement