[Vuejs]-How to modify only a nested array property in store with vuex

0👍

At store.js you are initializing storeInfo as null.

push is a method that works only for arrays, so it won’t work on a null variable.

Try to set storeInfo as an empty array instead:

export const store = new Vuex.Store({
  state: {
    storyInfo: []
  },

  ...

0👍

Posting my own solution. In Store, replace ‘addInfoToStory’ mutation with the story path of what needs to change:

addInfoToStory (state, payload) {
  state.storyInfo.episodes = payload
}

this will modify only that property in state.

Leave a comment