I Used showToast() method to get a success message with a toast when my method work correctly but I get the same toast message even if my method don't return any value (the case when I get an error I have the get the same message ) I don't know where is the problem
@track canc = false ;
myMethod(){
getName({TemplateId: this.recordId, value : this._selected.toString()})
console.log('record id is:'+this.recordId);
console.log('selected is: '+this._selected);
if(this.canc){
console.log('success'+this.canc);
const event = new ShowToastEvent({
title: '',
message: 'successfully',
variant: 'success',
mode: 'dismissable'
});
this.canc= true;
this.dispatchEvent(event);
this.dispatchEvent(new CloseActionScreenEvent());
}else {
console.log('eeeeeroooooooooorrrpopup'+this.canc);
const evt = new ShowToastEvent({
title: 'Error',
message: 'Please check that all rules are respected',
variant: 'Error',
mode: 'dismissable'
});
this.dispatchEvent(evt);
}
}