Hello i am trying to show toast message in aura but i am unable to do so .Can you please review my code and tell me whats the problem .
component.cmp
<aura:component >
<lightning:button label="showToast" onclick="{!c.toaster}"/>
</aura:component>
controller.js
({
toaster : function(component, event, helper) {
var toastSuccess = $A.get("e.force:showToast");
toastSuccess.setParams({
title : 'Success',
message: 'Record saved successfully',
duration:' 5000',
key: 'info_alt',
type: 'success',
mode: 'pester'
});
toastSuccess.fire();
}
})
and i am getting error like
This page has an error. You might just need to refresh it. Action failed: c:validation2$controller$toaster [Cannot read properties of undefined (reading 'setParams')] Failing descriptor: {c:validation2$controller$toaster}