Skip to content

I’ve got different behavior for object assign on localhost vs Server

Why the Object.assign works fine on Localhost but on server it does not ?

My vue app is hosted on S3 and everything works fine besides the Object.assign.

The remote api is being called properly and the update is ok, but the object is not being assigned and I got an empty error in the catch. log for console.log(JSON.stringify(e)) is just {}.

        .put(this.url + "/client/" +, {
          contactName: item.contactName,
          phoneNumber: item.phoneNumber,
        .then((response) => {
          Object.assign(this.client[this.editedIndex], item);
        .catch((e) => {
          this.dialogError = true;

I have tried change the object assign like this Object.assign({}, this.client[this.editedIndex], item);, but I got any unexpected behavior.


The error you get is most likely caused by an empty value of this.client[this.editedIndex]. Take a look on the below example:

(new Promise((resolve) => { resolve(); }))
  .then(() => { 
    Object.assign(undefined, {a: 1}); 
  .catch((e) => { 
    console.error('error', JSON.stringify(e)) 


error {}

Replacing undefined by null gives similar results. Therefore I would assume that there is no value at your this.client at this.editedIndex key.

In error logging you should avoid using JSON.stringify() with Error instances, as JSON.stringify does not know how to handle it:

> JSON.stringify(new Error('message'))

You are losing all the information – like message, stack etc.