DEV Community

Jatin Agrawal
Jatin Agrawal

Posted on

JS Promise Problems

When I return the temp variable it returns a promise instead of value. So does anyone know how to solve this?

Top comments (2)

Collapse
 
codefinity profile image
Manav Misra

Code example?
Generally, this means that your 'results' are 'wrapped' in a Promise. You can chain a .then( afterwards to try to resolve this.
You can chat me if you need some additional basic help with this.
Also, you should add the tag '#help' on your post.
Good luck.

Collapse
 
jithinzachariah profile image
Jithin Zachariah

To get the the value from a function that returns a promise you either need to append "then" with the function like
myFunc(params).then((data)=>{
console.log(data)
})
else much better is to use async await syntax
const data = await myFunc(params)
dont forget to mark the parent function async to use await inside it..