How to use vuex-rest-api with nuxt.js auth-module
See original GitHub issueHey I have the following issue…
I need nuxt auth-module to work with that package but at the point of creation I cant pass any axios instance, and thre is no global one. The result is that I get 401 response as I cant use the correct axios instance with the auth logic. Any idea?
in Nuxtj.s I create a store
import userStore from './users'
const createStore = () => {
return new Vuex.Store({
state: {
},
mutations: {
},
modules: {
users: userStore
}
})
}
export default createStore
users store
import Vapi from 'vuex-rest-api'
const userStore = new Vapi({
baseURL: '/api',
state: {
users: [],
groups: []
}
})
.get({
action: 'getUsers',
property: 'users',
path: '/users/getUsersTableData'
})
.get({
action: 'getGroups',
property: 'groups',
path: '/users/getGroupsTableData'
})
export default userStore.getStore()
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Setup - nuxt auth docs
Check the Nuxt.js documentation for more information about installing and using modules in Nuxt.js. ... When adding auth-module to a new Nuxt ...
Read more >How To Implement Authentication in a Nuxt.js App
In this tutorial, you'll implement authentication in a Nuxt.js app using the Auth module. For the purpose of this tutorial we'll be using...
Read more >Nuxt.js And Express.js Authentication with Auth Module and JWT
Hi, today we want to build an authentication app with Nuxt.js and Express.js, we'll focus on the front-end, and nuxt auth module and...
Read more >How to add authentication to your universal Nuxt app using ...
Installation of axios and auth modules; Configuration needed in nuxt.config.js; Using the state from auth module to check if user is logged ...
Read more >Authentication in Nuxt app - BlowStack
npm i @nuxtjs/auth After installation add auth module to the nuxt config. Notice that this module requires axios to work so if you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
found a solution for now:
I can register it by using the
registerModule()
method on the store, inside a plugin that is loaded after the axios initialization.plugins/init-store-modules.js
store/index.js
You could also register that inside the plugin but I like to have the module registration inside the store.
@christianmalek Maybe that should be added to the readme with an example or similar.
@juandl But you don’t pass any specific axios instance in your code example which was necessary for nuxt-auth @appinteractive, doesn’t it? So how does this work?