Hey, I've got problem with Vuex and fetch data. When i click to change route from menu it works but when i refresh page "f5" then it doesn't. But when I add console.logs I see that it works in terminal but I see that store is filled but I don't see it in browser. I do something like this
in index.vue
<script>
export default {
asyncData ({store}) {
store.dispatch('GET_CATEGORIES')
},
computed: {
categories () {
return this.$store.state.categories
},
category () {
return this.$route.params.category
}
}
}
</script>
in store/index.js
export const state = () => ({
categories: []
})
export const mutations = {
SET_CATEGORIES (state, categories) {
state.categories = categories
}
}
export const actions = {
async GET_CATEGORIES ({commit}) {
const categories = await this.$axios.$get('http://icanhazip.com')
commit('SET_CATEGORIES', categories)
}
}
<!--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/c1517">#c1517</a>)</em></sub></div>