I'm trying to use Vuex store in my Nuxt project. After following a guide on how to get started, I'm getting a this.$store is undefined
error.
store/index.js file:
export const state = () => ({
userdata: {}
})
export const mutations = {
setUserdata(state, value){
state.userdata = value
}
}
export const getters = {
GetUserdata(state){ return state.userdata}
}`
pages/login.vue script:
import Vue from 'vue'
export default Vue.extend({
name: 'LoginSuccessPage',
async created() {
var token = this.$route.query.token
var data = await fetch("http://localhost:3500/profile/" token)
var jsondata = await data.json()
this.$store.dispatch("userdata",jsondata)
}
})`
CodePudding user response:
Removing vuex
from package.json
fixed the issue.