Take a look at the codes below:
fetchServerData: function (component, event, helper) {
//calling Apex methods, fetching data etc..
}
updateData: function (component, event, helper) {
var fetchServerData= component.get("c.fetchServerData");
$A.enqueueAction(fetchServerData);
//update logics in JS etc.
}
As you can see, I'm calling the fetchServerData from the updateData method. But, since JS in Salesforce works asynchronously, I want to control the flow of it. I want to execute the fetchServerData first then go to the update logic section, not before that. How can I achieve it? FYI I can only update the updateData method, not the fetchServerData.