Because Lightning Web Components so often wrap objects in proxy objects, we long ago created a deProxyObj in order to be able to log to the console while debugging.
const deProxyObj = (proxyObj) => {
return JSON.parse(JSON.stringify(proxyObj));
};
It's simple and allowed us to investigate proxy object contents while building the component. But a few months ago (don't know exactly when) this started returning a proxy object back, and I don't understand why. Finally decided to try to fix it, and did this:
const deProxyObj = (proxyObj) => {
const str = JSON.stringify(proxyObj);
console.log('str', str);
const res = JSON.parse(str);
console.log("res", res);
return res;
};
When this gets executed, the log looks something like this (for data returned by Apex):
str {"0":{"Id":"a048K000000oRbnQAE","Address__c":"789 Third ...
res Proxy {}
So I'm successfully getting the proxy's contents as a string but then when I parse that string instead of giving me a standard object, it's wraping the object in a proxy object again, defeating the entire purpose.
So first, why did this used to work and now doesn't. And second, how can I extract the proxy object so I can investigate its contents for debugging purposes?
"lockerServiceNext": falsetoproject-scratch-def.json, spun a new scratch org and that fixed it. Please post an answer so I can give you the credit.