[Vuejs]-Undefined vuex 3 state variable

0👍

I found the issue. As specified in the Vue 2 API, Vue can only guarantee that an object will be reactive if it was properly initialized.

In my Vuex state I had indeed initialize the product object that I was trying to access through this.$store.getters.getProductById(this.id). The empty structure looked like this:

product: {}

But I was missing an array that should be places inside a product’s nested object. So finally I solved the problem by initializing the structure as follows:
`

product: {
  color_group: {
    colors: []
  }
}

`
And that was all.

👤Erwol

Leave a comment