• Yogesh Upadhyay 14
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

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;
    }
}