See real values instead of proxy in console.log

LWC : See the real values contained in proxy objects

While debugging your Lightning Web Components (LWC) it will be frustrating to get the real values by using Console.log()

Proxy values displaying in console

Now lets look at simple ways to see values inside proxy objects like this :

real values displaying in console

Steps to follow :

Step 1 : Enable Debug Mode for you User

Step 2 : Naviagte to page where your LWC is placed.

Step 3 : Open Chrome Dev Tools by Ctrl_Shift+I or Right click on the page and click inspect

Step 4 : click on setting

Seeing in Chrome dev tools

Step 5 : Naviage to Preference -> Enable Custom Formatter and check it

Preference -> Enable custom formatters

Thats it Done

Now if you check console you will be able to see real values

real values displaying in console

Now we will be able to see the real values in Console.log() statement without having to write the below code everytime.

console.log(JSON.parse(JSON.stringify(myObject)));
JavaScript

What if your unable to turn on Debug Mode ?

In some cases where your unable to turn on debug mode. You get values from the Proxy Object by simply right clicking the Proxy Object and slect copy object . Then paste it somewhere to get the value.

right click proxy oobject and click copy object
Right click on Proxy Object
read values pasted inside console
paste the copied content

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights