You need to sign in to do that
Don't have an account?
JeffreyStevens
lwc apex call returns [object Object]
So, I have a lightning web component that calls an APEX method to return something. When I try to display what the APEX returns, I always get [object Object] in the html.
Here's the code:
Does anybody see my issue?
Thanks!
Here's the code:
//.js.... import { LightningElement, api, wire } from 'lwc'; import acceptRtnSomthing from '@salesforce/apex/HelperAccount.acceptRtnSomthing'; export default class UltimateParentMRR extends LightningElement { @api recordId; somethingReturned = "Value in .js...."; @wire(acceptRtnSomthing, {recId : '$recordId' }) somethingReturned; } // HTML.... <template> <lightning-card title="Ultimate Parent MRR" icon-name="standard:account"> <div class="slds-m-around_medium"> {somethingReturned} </div> </lightning-card> </template> // APEX... @AuraEnabled (cacheable=true) public static string acceptRtnSomthing(string recId){ return recId; }If I comment out the call to the APEX - I get "Value in .js...." in the HTML output.
Does anybody see my issue?
Thanks!
Can you try after decorating somethingReturned with track or api? also in your html file replace {somethingReturned} with {somethingReturned.data}
Thanks.
All Answers
All wire requests have two attributes upon returning: data and error. I needed to use the .data attribute.
So - {somethingReturned.data}
Can you try after decorating somethingReturned with track or api? also in your html file replace {somethingReturned} with {somethingReturned.data}
Thanks.