Video Thumbnail

Unlock this lesson

Sign up for a plan to instantly unlock all premium lessons.

Unlock Lesson

Premium Features

Video unavailable for download

9. Restricting Pages with Vuex

store/index.js
export const state = () => ({
  user: null
})

export const mutations = {
  SET_USER(state, user) {
    state.user = user
  }
}

export const actions = {
  nuxtServerInit({ commit }, { req }) {
    if (req.session && req.session.user) {
      commit('SET_USER', req.session.user)
    }
  }
}

Comments

Want to participate?

Create a free Chris Courses account to begin

v
victor posted 6 years ago

after copying, pasting and saving the code in the store folder the vue devtool shows no Vuex store detected