1

I am receiving response from apex class in this format

[ { "Id" : "some record id" , "Name" : "opportunity name" , "Status" : "New"} ]

I am getting this response in .then(response => {

  • If I use console.log(response) then I am getting proxy object.
  • I use console.log(JSON.stringfy(response) then I am getting stringifyed data( plain data)

when I am setting that response to a variable called

@track oppList = [];

oppList = JSON.stringfy(response);

And when doing console.log(oppList) I am again getting proxy format

I need to use oppList in template for:each Like

<template for:each item={oppList} for:item="opp">
<p key={opp. Id} > {opp. Name}  
{opp.Status}
1
  • 4
    Proxy is just how Locker Service represents read-only objects. It should have no effect on your ability to get the values from the object. You don't need to serialize/stringify the object to JSON. Just use it like a normal variable.
    – sfdcfox
    Commented Apr 1, 2022 at 12:34

1 Answer 1

1

In addition to the serialization that you need to remove, it looks like you are not writing your data to the class variable - which will give an undeclared property warning.

Change oppList = JSON.stringfy(response);

To this.oppList = response.

Also, there is one more potential issue - in your template you have written your object property getter syntax with a gap. I don't think this will work. You have the classic problem where you have more than one bug, so any fix to one of them appears not to work.

Change <p key={opp. Id} > {opp. Name}

To <p key={opp.Id} > {opp.Name}

You must log in to answer this question.

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