You need to sign in to do that
Don't have an account?

Lwc return value is [object Object]
Hi everyone can you please help me i am getting object object as return value.
js code :
import { LightningElement, wire, track } from 'lwc';
import mapDemo from '@salesforce/apex/Utility.mapDemo';
export default class LwcUtility extends LightningElement {
@track name="Yogesh Upadhyay";
@track message="Welcome";
@track record;
@track error;
@track maps;
@track conList= [
{
id:'12345678',
name:'One two ka four',
Phone:'100'
},
{
id:'12345678',
name:'One two ka five',
Phone:'101'
},
{
id:'12345678',
name:'One two ka six',
Phone:'102'
}
];
@wire(mapDemo)
result({error,data}){
if(data){
this.record = data;
console.log("return is "+this.record);
JSON.stringify("hello",data);
}
if(error){
this.error= error;
console.log("retrun is "+this.error);
}
}
}
apex :
public with sharing class Utility {
public Utility() {
}
@AuraEnabled
public static map<String,Integer> mapDemo(){
map<String,Integer> testmap = new map<String,Integer>();
testmap.put('avab',2);
testmap.put('avab',2);
testmap.put('avab',2);
testmap.put('avab',2);
return testmap;
}
}
Hello Yogesh,
Try this:
var accData = JSON.stringify(received_data);
var finalData = JSON.parse(accData);
@Yogesh,
All wire requests have two attributes upon returning: data and error. so you have to use the .data attribute.
So - in your html file use it as {ReturnValue.data}
Refer to this link: https://developer.salesforce.com/forums/?id=9062I000000XlRmQAK
Note: Mark it as answer if this resolves your issue.
var data = JSON.stringify(received_data);
it will resolve your problem