How can I access vue-cookies in a vuex store?
You can install js-cookie library and than access cookie like this in vuex store:
import Cookies from 'js-cookie'
const getters = {
isLoggedIn: function (state) {
return !!state.email && !!Cookies.get('access_token')
}
}
you can do (in store.js
)
import Vue from 'vue'
...
someAction () {
Vue.prototype.$cookies.set("token", response.token, "7d");
}
When using vue-cookies
in your app
In your store.js
, you can
import cookie from 'vue-cookies'
.....
action(){
cookie.get('token');
}