Skip to content
Advertisement

How to return values from the Object Promise in Jquery

I am trying to return the values from the object of Promises, the values are printed in the console but when I am displaying it on the HTML, it is showing “OBJECT PROMISE” in place of the returned Value. My code is

JavaScript

The type of val returned is String here. but as soon as it is called from an object, it gives the above mentioned output, i.e “Object Promise” The code for the Object is

JavaScript

For Document manipulation, I am using the following method

JavaScript

It would be really great if anyone could help with this one as I couldn’t find any solution that could resolve this issue. Thank You!

Advertisement

Answer

Try to wrap everything in an async function and use await every time you call your function:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement