import VuexORM from '@vuex-orm/core' const cookieparser = process.server ? require('cookieparser') : undefined export const plugins = [ VuexORM.install() ]; export const actions = { async nuxtServerInit({commit, dispatch}, {req}) { let bearer = null let accessId = null if (req.headers.cookie) { const parsed = cookieparser.parse(req.headers.cookie) try { bearer = parsed.BEARER } catch (err) { // No valid cookie found } try { accessId = parsed.AccessId } catch (err) { // No valid cookie found } } commit('myProfile/setBearer', bearer) commit('myProfile/setAccessId', accessId) await dispatch('updateProfile') }, async updateProfile({ commit, state }) { const my_profile = await this.$http.$get(`/api/my_profile/${state.myProfile.accessId}`) commit('myProfile/setProfile', my_profile) }, }