in my store i have next code:
import Cookies from 'cookies-js'
const state = {
user: null,
token: Cookies('token') ? Cookies('token') : null
}
export default {
state,
mutations
}
end i can see next error:
Nuxt.js Error:
Error: Cookies.js requires a `window` with a `document` object
at factory (D:\prj\nuxt\node_modules\cookies-js\dist\cookies.js:12:19)
at Object.module.exports.Object.defineProperty.value (store/user.js:9:17)
at __webpack_require__ (webpack:/webpack/bootstrap dfe6cf738e49c9418da8:25:0)
at webpackContext (webpack:/store ^\.\/.*\.js$:6:0)
at getModule (.nuxt/store.js:9:13)
at Object.module.exports.Object.defineProperty.value (.nuxt/store.js:50:19)
at __webpack_require__ (webpack:/webpack/bootstrap dfe6cf738e49c9418da8:25:0)
at Object.<anonymous> (server-bundle.js:805:68)
at __webpack_require__ (webpack:/webpack/bootstrap dfe6cf738e49c9418da8:25:0)
at Object.<anonymous> (server-bundle.js:1908:65)
at __webpack_require__ (webpack:/webpack/bootstrap dfe6cf738e49c9418da8:25:0)
at server-bundle.js:95:18
at Object.<anonymous> (server-bundle.js:98:10)
at evaluateModule (D:\prj\nuxt\node_modules\vue-server-renderer\build.js:6967:21)
at D:\prj\nuxt\node_modules\vue-server-renderer\build.js:6985:15
at D:\prj\nuxt\node_modules\vue-server-renderer\build.js:6983:12
but i see examples with this code snd it work... what i can do for work with cookies-js?
@StudiowebPro Handeling cookies in server side is different from client side. (See simple implementation here)
@pi0 in this issue #429 a person writes that this code works ...
@pi0 Thank's, i decide problem with set abd load token, your code help me.
You can use https://github.com/nuxt/nuxt-modules/blob/master/modules/auth/store.js instead :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.