[Vuejs]-If the same value is being printed on the console before calling axios, why is it that a different value gets sent to the server?

0👍

After logging a really complex control flow I finally got to the point where I knew which properties I had to mutate. However, it turns out that in Vue 2 mutating inline properties is an anti-pattern. The capability of mutating inline props was deprecated from the previous Vue version in order to be consistent with the library’s fully reactive paradigm. So what happens is that if you try to mutate an inline property, when the component re-renders, such property will be set back to its default (or previous) value.

This is solved by adding a computed property that’s a copy from the property that you want to mutate.

//Somewhere else in the code the property is defined
property: null

//Add the computed property
data: function () {
    return {
      mutableProperty: this.property,
    }
}

Leave a comment