I am trying to pass a list of objects to Apex from an LWC controller, and it looks like the Apex controller is getting the right sized list, but nothing is populated. Does anybody have any idea of what could be the problem?
Component JS code
refreshPeople() {
let xxx = [];
xxx.push({name : 'aaa', email : 'bbb'});
xxx.push({name : '111', email : '222'});
getPeople({peopleInfo: xxx})
.then(result => {
console.log('#### HERE');
this.allPeople2 = result;
})
.catch(error => {
//Error Handling goes here
});
}
Apex:
@AuraEnabled(cacheable = true)
public static List<EmailPerson> getPeople(List<EmailPerson> peopleInfo) {
try {
System.debug('####' + peopleInfo);
return null;
} catch (Exception e) {
throw new AuraHandledException(e.getMessage() + ' ' + e.getStackTraceString());
}
}
public class EmailPerson {
@AuraEnabled
public Id id;
@AuraEnabled
public String name;
@AuraEnabled
public String email;
@AuraEnabled
public Id recordTypeId;
@AuraEnabled
public String recordTypeName;
}
Note: I've tried @wire
, the behavior is the same. The list sees the two items, but none the values on the properties are assigned
<17:00:38:006 USER_DEBUG [20]|DEBUG|####(EmailPerson:[email=null, name=null], EmailPerson:[email=null, name=null])