Errors: Error in created hook (Promise/async): "TypeError: state.push is not a function" TypeError: state.push is not a function
Method in page
created: async function () { this.$store.commit('TicketSystem/ADD_BOARDS', (await this.$axios.get('https://localhost:7166/boards')).data) }
mutation method
export function ADD_BOARDS (state, payload) { state.push(payload) }
Object
[{"id":1,"name":"string"}]
I build Backend in .NET and Frontend in Quasar and now I am trying connect them. I created Page, Method on created and mutation method.
The problem is that state is an object, not an array. But you can add an array property to the state and store your data there:
{
state: {
boards: []
},
mutations: {
ADD_BOARDS (state, payload) {
state.boards.push(payload)
}
}
}