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;
            .catch(error => {

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'


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 :-)

  • 1
    P.S. This has nothing to do with locker service, it has to do with not mutating the cache of a cachable Apex method. If you were allowed to modify the object, you'd mess up the cache, so the object is read-only to prevent this from happening.
    – sfdcfox
    Apr 6, 2019 at 15:36
  • Thanks. I don't know why, but I couldn't find the question linked above. It's surely a duplicate.
    – Wookie88
    Apr 8, 2019 at 7:27

1 Answer 1


Try using ES6 syntax, looks much cleaner and simpler.

const fieldValue = (whatever data to add)
settings = {...settings, fieldValue};

Not the answer you're looking for? Browse other questions tagged .