0

Is it possible to access the value that represents the promise object directly?

Promise { <state>: "fulfilled", <value>: {…} }

<state>: "fulfilled"
​
<value>: Object { code: 3000, data: (15) […] }

Thanks!

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
eshalit
  • 11
  • 4
  • 1
    I’m not sure what you’re asking; a promise is an object like everything else. Can you be more specific? Are you asking how to access those "properties" directly? There’s no standard way to do that, but you can do things like [this](https://ourcodeworld.com/articles/read/317/how-to-check-if-a-javascript-promise-has-been-fulfilled-rejected-or-resolved) – Dave Newton Jun 25 '21 at 20:16
  • Thanks for the info! It's been helpful. I was just wondering if there's a direct or even a hardcoded way to access the value key inside a fulfilled promise. The value key contains the data object that I need to extract values from. – eshalit Jun 30 '21 at 21:07
  • I am using an external API and I have been able to chain multiple promises, all fulfilled, but I can't seem to find a way to access the object directly unless I return a result value from it using a 'then'. This makes the process cumbersome. The value param inside the promise is the key of a value which is an object right? Is there a way to extract it out? I guess that's my question. – eshalit Jun 30 '21 at 21:07

0 Answers0