3

I'm trying to understand returning info from APEX in the lwc and showing it in the html. I'm calling the APEX, but the HTML continues to return "[object Object]"

Can you see anything wrong with my 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;
}

Again - output in the HTML is just ... [object Object]

If I comment out the call to the APEX - the HTML output is Value in .js....

1 Answer 1

1

All wire requests have two attributes upon returning: data and error. You're looking for the data attribute.

{somethingReturned.data}
1
  • Yep - that was it! Thank you! Oct 11, 2019 at 15:26

You must log in to answer this question.

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