0

Hi guys
I'm trying to get some "hardcoded" values from an apex Method, but when I write a console.log it's comming empty. enter image description here

Here's the code I'm working on:

@wire(getValues)
wiredValues({error, data})
     if(data) {
     console.log("Data::::::",data);
     this.getVal = JSON.stringify(data);
     } else if(error){
           this.error = error;
           this.getVal = undefined;
           console.log("No values");
     }

Here's my apex method(I'm trying to make kind of "fake" callout but i'm not sure if im right):

public without sharing class getSomeValues {
       @AuraEnabled(cacheable = true)
       public static List<wrapVal> getWrapVal() {

        HttpResponse request = new HttpResponse();
        request.setBody('{"Values": ["1000", "2000", "3000", "4000", "5000"]}');
        Map<String, Object> results = (Map<String, Object>) 
        JSON.deserializeUntyped(request.getBody());
        List<Object> sumVal = (List<Object>) results.get('Values');
        List<wrapVal> newLstValues = new List<wrapVal>();

        for (Object getValues : sumVal ) {
             wrapVal newLstValue = new wrapVal();
             newLstValue.nwValue = String.valueOf(getValues);
             newLstValues.add(newLstValue);
             System.debug("getValues::::::"+ newLstValue.nwValue);
       }
        return newLstValues;
  }

  public class wrapVal {
  public String nwValue { get; set; }
  }

Debug: enter image description here

So idk what i'm doing wrong, if can share with me some advice or documentation it'd be great. Thanks

1 Answer 1

1

It seems like you need to decorate the properties of the class wrapVal with @AuraEnabled. Otherwise LWC won't receive them.

 public class wrapVal {
  @AuraEnabled
  public String nwValue { get; set; }
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.