Avoid Proxy objects in debug statements for a Lightning component

This may be a very basic questions, but I don’t seem to find the answer for it! Basically I want my console.log statements to show all the good stuff instead of the LockerService Proxy object. Is there a way to do that without setting the API version to lower than 40.0? Even then I’m not sure if that’ll do it.

For now I’m using JSON stringify.

Answer

This will get it out of proxy and back into nice, readable format.

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

Used it so much I made a snippet of it (vscode, sublime, maybe others)

"xlog": {
    "prefix": "xlog",
    "body": [
        "console.log(JSON.parse(JSON.stringify(${1:var}));"
    ],
    "description": "logs json stuff through proxy"

Attribution
Source : Link , Question Author : Mossi , Answer Author : Simon Lawrence

Leave a Comment