I am facing issue with LWC, probably connected to the LockerService's Proxy objects.
My code
I am getting the list of custom objects defined in one of my Apex classes by calling Apex method from LWC JS file:
getSettingsForConfigType({configType: this.codeConfigType})
.then(settings => {
//this.fieldList = settings;
this.prepopulateConfig(settings);
})
.catch(error => {
this.toastError(error.body.message);
})
The problem
The problem is I need to populate the settings
object returned from Apex with additional field. This field is not defined in Apex (and I don't want it to be defined, it will be used only on LWC side). Whenever I try to add new field called fieldValue
either with obj.fieldValue = ...
or obj['fieldValue'] = ...
syntax I get forrowing error:
TypeError: 'set' on proxy: trap returned falsish for property 'fieldValue'
Question
Is there any way to overcome this limitation or maybe I am missing something here?
P.S. Dirty workaround
settings = JSON.parse(JSON.stringify(settings));
However, it seems to be a bit ugly trick. That's why I posted the question :-)