I am writing my own project in Nuxj.js and nearly everything is working. There is 1 thing that isn't working and I'm hoping you can help me.
I am using the Vuex store in Nuxt.js and I have everything setup. I can confirm that my action is called and that the mutation called in the commit works. However if I change anything in the state in the mutation ten the state doesn't change. Here is my action
import axios from 'axios'
import * as ACTIONS from './action-types'
const actions = {
async [ACTIONS.FETCH_TRAINING_TYPES_ACTION] ({ commit }) {
let {data} = await axios.get('http://localhost:8080/api/students')
commit('setStudents', data)
}
}
export default actions
The commit invokes the following mutation
const mutations = {
setStudents (state, payload) {
console.log('1: ' + payload)
state.students = payload
console.log('2: ' + state.students)
}
}
export default mutations
The first console log prints the payload which contains the right data so the mutation is invoked properly. The second console log prints the state.students and it prints the right value so the state is updated. However when viewing the vex state in the chrome Vue extension I can see that the state is empty and also if I print the state value state.students it's empty.
It's starting to look like a bug where the state changes aren't persisted or something.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2098">#c2098</a>)</em></sub></div>