I have a custom lwc component embedded inside another custom aura component.
This lwc dispatches custom event with data for aura to retrieve and process but I can't get any info although it's capturing the event.
customlwc.js
handledataChange(event){
this.dispatchEvent('handleResponse', { message : event.detail.value });
}
customaura.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction">
<c:customlwc onhandleResponse="{!c.handleResponse}"/>
</aura:component>
customaura.js
({
handleResponse: function(component, event, helper) {
console.log(event.getParam('message')) //this displays undefined
},
})
Is there something I'm missing or isn't this the proper way to retrieve event info?
EDIT (added lwc code for event launch)
@wire (getInitialInfo, {recordId : '$recordId'}) wiredGetInitialInfo ({error, data}){
//Data
if(data){
//Success
if(data.success){
this.dispatchEvent(new CustomEvent('handleSCResponse', { message : 'Operation completed successfully' }));
}
//Error
else{
//for enclosing aura
this.dispatchEvent(new CustomEvent('handleSCResponse'), { message : 'Error found '});
}
}
//Error
else if(error){
this.dispatchEvent(new CustomEvent('handleSCResponse'), { message : 'Unexpected error' });
}
}