Reputation: 1
I have an nuxt.js
app that a user can log in to. Whenever the user is authenticated using the nuxt/auth
module. I want the app to fetch some data using the nuxtServerInit
.
Currently I have this in my nuxtServerInit
:
export const actions = {
async nuxtServerInit({ dispatch }) {
if (this.$auth.loggedIn) {
await dispatch('products/getProducts')
...
}
}
}
This works well if I'm authenticated and the page is refreshed. The problem seems to be whenever I'm redirected after authentication, these actions are never called, thus not populating the store
.
I have tried to use the fetch
method instead, but in only works on the page with the fetch
statement, not every page in my application. Also I don't want the http calls to be made with every page change.
Upvotes: 0
Views: 620