Skip to main content

I am getting below error when imperative method return null values.

Cannot add property 0, object is not extensible

name=[];

callaccountName(){

getaccountList().then(data => {

this.name = data;

})

}

Error :Cannot add property 0, object is not extensible

 
1 respuesta
  1. 1 oct 2020, 19:27
    Hi Kishore,

    The response from apex might have become non-extensible with additional parameters.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions

    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.

    Regards,

    Anutej