+ Start a Discussion
Kishore Vamsi 6Kishore Vamsi 6 

how to handle error in imperative method for below code

I am getting below error when imperative method return null values.
Cannot add property 0, object is not extensible


        getaccountList().then(data => {
                this.name = data;

Error :Cannot add property 0, object is not extensible

ANUTEJANUTEJ (Salesforce Developers) 
Hi Kishore,

The response from apex might have become non-extensible with additional parameters.
As workaround you can use result = Object.assign({}, result) for objects, or item = Object.assign({}, item) in a loop for each item in result for arrays
Or one more dirty hack is JSON.parse(JSON.stringify(result));

I hope this helps and in case if this comes in handy can you please choose this as best answer so that it can be used by others in the future.