[Vuejs]-Vuex mutations setting state

0👍

Based on your response the output you get is

{...paylad.quiz}

Output

{
0: {id: 1, date_playable: "2019-10-15 00:00:00", created_at: "2019-10-15 16:38:23", updated_at: "2019-10-15 16:38:23", questions: Array(15)}
}

Here your are having quiz in array format, when you do spread operator(…) inside an object ({}), it tried to create objects keys using array index and values as array value

Instead you can do

mutations: {
    setQuiz(state, payload) {
        state.quiz = payload.quiz;
    },
},

Leave a comment