From 0e48eb634b4697849ee8d9344b971530c303a156 Mon Sep 17 00:00:00 2001 From: Alexandre David Date: Tue, 21 May 2019 18:56:37 +0100 Subject: [PATCH] examples(auth-jwt): use named store export to prevent warning (#5775) --- examples/auth-jwt/store/index.js | 48 ++++++++++++++------------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/examples/auth-jwt/store/index.js b/examples/auth-jwt/store/index.js index 8754193c40..b37ced1dac 100644 --- a/examples/auth-jwt/store/index.js +++ b/examples/auth-jwt/store/index.js @@ -1,32 +1,26 @@ -import Vuex from 'vuex' - const cookieparser = process.server ? require('cookieparser') : undefined -const createStore = () => { - return new Vuex.Store({ - state: { - auth: null - }, - mutations: { - setAuth(state, auth) { - state.auth = auth - } - }, - actions: { - nuxtServerInit({ commit }, { req }) { - let auth = null - if (req.headers.cookie) { - const parsed = cookieparser.parse(req.headers.cookie) - try { - auth = JSON.parse(parsed.auth) - } catch (err) { - // No valid cookie found - } - } - commit('setAuth', auth) +export const state = () => { + return { + auth: null + } +} +export const mutations = { + setAuth(state, auth) { + state.auth = auth + } +} +export const actions = { + nuxtServerInit({ commit }, { req }) { + let auth = null + if (req.headers.cookie) { + const parsed = cookieparser.parse(req.headers.cookie) + try { + auth = JSON.parse(parsed.auth) + } catch (err) { + // No valid cookie found } } - }) + commit('setAuth', auth) + } } - -export default createStore