Video Thumbnail

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

UNLOCK LESSON

Premium Features

Download Video

9. Restricting Pages with Vuex

Published 4 years ago

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

Login
v
victor posted 3 years ago
0

Providing the lift to launch your development career

© 2024 Chris Courses. All rights reserved.