[Vuejs]-Vuex Mutation: Cannot read properties of undefined (reading 'Id')

0šŸ‘

I answered it myself by making it less verbose.

Since Iā€™m just looking for the Id I did it in a variable.

OLD:

  state.performBooking.sessions.find((o,i) => {
    if(o.Id === sessionData.Id){
      state.performBooking.sessions.splice(i, 1)
    } 
  })

NEW:

let localSessionIndex = state.performBooking.sessions.findIndex(o => o.Id === sessionData.Id)
state.performBooking.sessions.splice(localSessionIndex, 1)

Leave a comment