I've run into an issue with returning data from Apex to LWC which I'm having trouble figuring out.
I've set up an LWC which calls an apex method to make a callout an return the result of said callout after some server-side processing has been made. On server side I save the processed data in an object "CreditDecision" which also is the method return type. I then pass back to the LWC as the response.
However, In the LWC, the response from the method call is blank. When i try to just send a string as a response the result is returned just fine.
Is this due to LWC just being able to recieve sObjects, List of sObjects and primitive datatypes as returned data, or am I missing something?
Heres the code:
Returned Apex Object
public class CreditDecision {
Account account {get;set;}
Opportunity opportunity {get;set;}
Boolean creditAuthorized {get;set;}
Decimal appliedCredit {get;set;}
Decimal approvedCredit {get;set;}
String creditRating {get;set;}
String decisionDesc {get;set;}
String dateOrdered {get;set;}
String error {get;set;}
}
And the LWC code
doCreditCheck({recordId: this.recordId,sObjectType: this.sObjectName,appliedCredit: this.appliedCredit})
.then(result => {
//For some reason the Result is empty {} when result isn't a primitive or sObject
const decision = result;
console.log('result: ' + JSON.stringify(result));
console.log('Result data: ' + result.data);
console.log(decision);
this.isLoading = false;
this.creditCheckCompleted = true;
if(decision === 'K') {
this.creditCheckControll = true;
}else if (decision === 'G') {
this.creditCheckApproved = true;
}else if (decision === 'A') {
this.creditCheckDeclined = true;
}
@auraEnabled
attribute to any of the members.