Can not access Vuex store object in the mounted hook

Viewed 111

I need to use Vuex state in mounted hook. But when I call dispatch I get {__ob__: Observer} object which does not contain expected data. I dont understand. Mounted hook should have access to all resources including Vuex store.

async mounted() {
    this.newShareToken = this.$route.query.token;

    console.log('mounted this.checkLocalStorageToken()');
    if( !this.checkLocalStorageToken(this.newShareToken) ) {
       ...
    }
}

// This is the problem. 
checkLocalStorageToken(token) {
   return !!this.$store.dispatch('campaign-new-share/checkShareToken', token);
},

and here is the code from Vuex store

checkShareToken: ({state, commit}, token) => {
    console.log(state.share_tokens);  // This is not the value but {__ob__: Observer}
    return state.share_tokens[token] ? state.share_tokens[token] : null;
}
0 Answers
Related