I was trying to create an apex method which will return a string whenever we click on the lightning component button. But it is giving no response. This is my Code :
COMPONENT:
<aura:component controller="CustomMassDownload" implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<div class="slds-p-top_xx-large">
<button type="button" onclick="{!c.downloadFile}" >Download</button>
</div>
</aura:component>
CONTROLLER:
({
downloadFile : function(component, event, helper) {
console.log('why?');
helper.getString(component,event,helper);
}
})
HELPER:
({
getString : function(component,event,helper) {
console.log('owl');
var action = component.get("c.ReturnString");
action.setParams({
abc: "djflskj"
});
console.log('puppy' + action);
action.setCallback(this,function(response){
console.log('issuccess');
var state = response.getState();
if(state === "SUCCESS"){
console.log('love');
}else{
console.log('hate');
}
});
}
public class CustomMassDownload{
@AuraEnabled
public static String ReturnString(String abc){
system.debug('aaaaaaaaaa');
return abc;
}
}