How do I wait for a command then execute another in a button click?

This may be trivial but I am stuck:
I have a button that I want to 1. clear a widget and THEN 2.execute a query once the widget has been cleared? How do I accomplish this?
If I just issue both commands in the button’s click JS they execute asynchronosuly.
{{resetWidget(“Table1”);;}} Those 2 things happen but the 2nd doesn’t wait for the first. In some of the examples like chaining queries.rum() they seem to have resolve/reject but how to I accomplish that with a method like resetWidget()?

Hey @fcatanzaro! The resetWidget method runs asynchronously currently. Could you please explain your use case for having to run these functions sequentially?