What is wrong here? I see only Error
on toast.
let toastEvent = $A.get("e.force:showToast");
action.setCallback(this,function(a){
let state = a.getState();
if(state == "SUCCESS"){
--------- //some actions
toastEvent.setParams({
title: "Success",
message: "Congratulations!",
type: "success"
});
toastEvent.fire();
} else if(state == "ERROR"){
let errors = a.getError();
toastEvent.setParams({
title: "Error",
message: errors,
type: "error"
});
toastEvent.fire();
}
});
Apex part:
} else{
throw new AuraHandledException('You already have this record!');
}