I've had a problem which my vuex state's only lasts for web page refresh. Once web page is refreshed, data in the vuex store is vanished.
For overcome that I've used nice pluggin called Vuex persistestate Now my vuex is persist.
But still I've a issue with the axios authorization header. I've set auth header in axios login action like this
actions: {
login({ commit }, payload) {
return new Promise((resolve, reject) => {
try {
axios.defaults.headers.common.Authorization = payload.token;
commit('setUser', payload);
resolve();
} catch (error) {
reject();
}
});
},
},
But this auth headers value got undefined if I hit the refresh button. How do I overcome this problem?