nuxt-community / legacy-modules

MIT License
1.28k stars 158 forks source link

how to add vuex module through nuxtjs module? (and auth module is out of date) #97

Open srghma opened 6 years ago

srghma commented 6 years ago

I'm trying to change auth module to my needs and with this index.js

const path = require('path')

module.exports = function nuxtAuthDevise (options) {
  this.addVendor(['cookie', 'js-cookie'])

  this.addPlugin(path.join(__dirname, 'store.js'))
}

and with original store.js I get an error

 ~/projects/vue-todolist/client   master ●  yd
yarn run v0.28.4
$ nuxt
[AXIOS] Base URL: http://localhost:3001/api/edge , Browser: http://localhost:3001/api/edge
  nuxt:build App root: /home/bjorn/projects/vue-todolist/client +0ms
  nuxt:build Generating /home/bjorn/projects/vue-todolist/client/.nuxt files... +1ms
  nuxt:build Generating files... +9ms
  nuxt:build Generating routes... +6ms
ReferenceError: ctx is not defined
    at eval (lodash.templateSources[17]:9:10)
    at Builder._callee2$ (/home/bjorn/projects/vue-todolist/client/node_modules/nuxt/lib/builder/builder.js:249:23)
    at tryCatch (/home/bjorn/projects/vue-todolist/client/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/home/bjorn/projects/vue-todolist/client/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/home/bjorn/projects/vue-todolist/client/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/home/bjorn/projects/vue-todolist/client/node_modules/nuxt/dist/nuxt.js:852:30)
    at /home/bjorn/projects/vue-todolist/client/node_modules/nuxt/dist/nuxt.js:863:13
    at <anonymous>
[nuxt] Unhandled promise rejection: ReferenceError: ctx is not defined

so, my question is how to add vuex module through nuxtjs module ? (I dont know whether nuxtjs/auth merged with root store or added as module, but I want it to be module (separate namespace))

This question is available on Nuxt.js community (#c60)
srghma commented 6 years ago

@pi0 any help? are auth module still correct?

pi0 commented 6 years ago

@BjornMelgaard As of lots of new changes it is not working now, I plan to update this module as soon as new vuex releases. Also for access vuex and store we can use plugins :)

srghma commented 6 years ago

:(( new version of vuex - vuex 3? O_O

pi0 commented 6 years ago

Not actually, we just need an enhancement which is merged and just awaits for next release that allows us access vuex in store actions. Without that, we need to pass everything as parameters to get working. Is your project on GitHub? I may help you before that module release :)

srghma commented 6 years ago

ah, this change. OK, I made a note))