custom widget property not defined (undefined), how to solve?

I have an application page that uses a custom widget that receives a Javascript variable as one of its property elements.

The return of the variable javaScript occurs after processing API calls, several lines of code to confirm the response, returning a Json. When viewing the return via a text element on the page itself, I can see it perfectly. However, when defining this variable as the custom widget property, I get that the return of my JS variable is not defined, within the controller code I placed a console.log for the property and I get the "undefined".

I believe that when the custom widget code is executed, the result of this JS variable is not ready yet. How to define this order of execution? Is there any detail that I should look at more closely? Can this be caused by the structure of my custom widget itself?

HI Jhonatan,

 

Could you share a page with the custom widget (or simplified versions of both) so we can see what is happening?

Thanks

The problem has been solved. When inserting the input variable of the custom Widget as a condition for Hidden parameter, the return content of the widget became visualized in the main page content. I confess that I did not understand the connection between elements, but that solved the problem.