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.

Here is how I generally work in chrome when i see a proxy object,

Use the chrome "store as global variable" on the proxy object as shown in the below screenshot

enter image description here

Then I just use the Javascript object.keys() and add a bit of Javascript in the console like below to print keys

for (let key of Object.keys(temp1)) {
        console.log(key + temp1);
}

That gets me what I need and then most of the times , I just have to rely on JSON.stringify() to see the output .

enter image description here

  • Thanks Mohith. That's pretty much my current approach except I am doing all of this right inside of the controller. But a sizeable benefit of your approach is that I don't have to jump back and forth to code. I like it. – Mossi Feb 8 at 7:20

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"

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.