How do I get the return value of the API in JS object, because the API is asynchronous

How do I get the return value of the API in JS object, because the API is asynchronous,if I immediately get the data in the JS function, the API.data value is wrong

@hou Here’s the link to the documentation around JS promises which might help - https://docs.appsmith.com/core-concepts/writing-code/javascript-promises

You can also have a look at our sample app with examples of using async-await - Appsmith

Please feel free to reach out in case of any queries.