0

I'm trying to get my head around the Promise API, and struggling.

This is what I've tried so far:

const myPromise = () => {
   return new Promise( (resolve, reject) => {
      var name = 'John'
      if (name === 'John') {
         resolve(name)
      }
      else reject('Anonymous')
   })
}

Then when I console.log(myPromise()), I get...

Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: "John"}

I would expect to get John back from this. As it stands, I don't know how to handle the data. Can anyone point out where I'm going wrong?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Paulos3000
  • 3,355
  • 10
  • 35
  • 68

0 Answers0