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);
            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;
  • It's empty because you haven't added @auraEnabled attribute to any of the members. Commented Dec 18, 2020 at 6:13

1 Answer 1


Make members public and @auraEnabled to make them available in the lightning component.

public class CreditDecision {
    public Account account {get;set;}
    public Opportunity opportunity {get;set;}
    public Boolean creditAuthorized {get;set;}

    // and so on 
  • 3
    Awesome, that did it. Thanks alot Rahul!
    – Cnork
    Commented Dec 18, 2020 at 7:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .