How I can get the store in javascript modules that doesn't have access to the nuxt context or a vue component?
import Store from '~store'
// or
const store = require('~store')
console.log(store)
// { createStore: [Getter] }
is not working any more in the latest versions.
Hi @LowM4N
The ~store alias is going to be removed, with 1.0, the plugins now receives the context :confetti_ball:
plugins/my-plugin.js
export default ({ store }) => {
// here you have store!
}
Keep in mind that nuxt.js call the methods of the plugins without waiting for their answer so they cannot be asynchronous (middleware are there for that).
Demo: https://complex-secretary.glitch.me/
Code: https://glitch.com/edit/#!/complex-secretary?path=plugins/test-store.js:3:59
:smile:
I've a problem with this modification...
I cannot get state from store in context...
@Atinux And to use the store inside a class? Like:
import { Model as BaseModel } from 'vue-api-query'
export default class Model extends BaseModel {
...
}
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.
Most helpful comment
Hi @LowM4N
The
~storealias is going to be removed, with 1.0, the plugins now receives the context :confetti_ball:plugins/my-plugin.jsKeep in mind that nuxt.js call the methods of the plugins without waiting for their answer so they cannot be asynchronous (middleware are there for that).
Demo: https://complex-secretary.glitch.me/
Code: https://glitch.com/edit/#!/complex-secretary?path=plugins/test-store.js:3:59
:smile: