[Vuejs]-TypeError: Cannot read property 'commit' of undefined

0👍

try

$store.commit('{fileName}/{mutatorName}', value);

in your case

$store.commit('store/setAuthentication', true);

0👍

Try this one.

    import Vue from 'vue'
    import Vuex from 'vuex'
    Vue.use(Vuex)
    
    export default new Vuex.Store({
        state : { 
            authenticated: false, 
        }, 
        mutations: {
            setAuthentication(state, data) {
                state.authenticated= data;
              },
        }, 
    })


this.$store.commit('setAuthentication',true);

Leave a comment