Object.assign throws error in axios then promise

I have this method in a vuetify datatable:

save() {
        let self = this;
            axios.patch(this.apiUrl + this.componentUrl + '/' + this.items[this.editedIndex].id, this.editedItem)
                .then(response => {
                    console.log(response);
                    Object.assign(self.items[self.editedIndex], self.editedItem);
                })
                .catch(function (error) {
                   console.log(error)
                });  
    },

The axios call returns response 200 OK but for some reason the object.assign line throws an error. catch fires but the console.log(error) returns

TypeError: Cannot convert undefined or null to object at Function.assign ()

If I comment out the object.assign line everything works ok.

If I add the object.assign above the axios.patch it works without error.



Read more here: https://stackoverflow.com/questions/64952876/object-assign-throws-error-in-axios-then-promise

Content Attribution

This content was originally published by grimdbx at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: