Hello everybody I am working with a LWC form that gathers the information from the user and send it to an apex function that validates the data. If this data is incorrect it send the list of errors of why is the data wrong. And I want that this data to be shown in different show toast events. The problem is that I am getting this instead of the message:
in my apex function I have the next code:
@AuraEnabled(cacheable=true)
public static List<ValidationError> getInfoFromLWC(String wrapperWithInfo){
MyClassName newInstance = new MyClassName();
WrapperInterface newWrapper = newInstance.createWrapper(wrapperWithInfo);
List<QX_ValidationError> listaConErrores = newWrapper.validate();
List<String> listaErrores = new List<String>();
System.debug('start validating...');
System.debug('validated...');
System.debug('messages...'+ newWrapper.validate());
if(listaConErrores.isEmpty()){
return null;
}else{
for(QX_ValidationError iError: listaConErrores){
listaErrores.add(String.valueOf(iError));
}
System.debug('lista de errores string...'+ listaErrores);
return listaErrores;
}
And in my .js I have the following code:
wrapperC101({wrapperWithInfo : JSON.stringify(this.createWrapper())}).then((result) =>{
const{data,error} = result;
this.data = result;
console.log('data from apex function...'+ this.data);
for (var iMessage in this.data){
const notificationError = new ShowToastEvent({
title: 'Error',
message: iMessage,
variant: 'error'
});
this.dispatchEvent(notificationError);
}
this.error = undefined;
}).catch((error)=>{
this.error = error;
this.data = undefined;
})
And the console log that shows me the data that comes from the apex function is the next one:
Could anybody help me to show the message error? Thanks