nuxtServerInit is never called
See original GitHub issuegenerate nuxt project with express, add store/index.js with nuxtServerInit:
import axios from 'axios'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export const state = () => {
return {
}
}
export const mutations = {
}
export const actions = {
// nuxtServerInit is called by Nuxt.js before server-rendering every page
async nuxtServerInit({dispatch, commit}, {req}) {
console.log("nuxtServerInit()");
},
async test({ commit }, { v }) {
console.log('store test: ', v)
}
}
but method test() runs fine from this.$store.dispatch(‘test’…)
probably nuxtServerInit() never called from nuxt.render
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
nuxtServerInit is not calling on production server - Nuxt.js
I run npm run build and then pm2 start npm --name "nuxt-project" -- start I am using pm2 for the production mode. Even...
Read more >Creating Server-side Rendered Vue.js Apps Using Nuxt.js
There is a problem: We see the original state for a second while the API runs. Later, we will use a solution provided...
Read more >Using nuxtServerInit in Vuex to Fetch Component Data
The nuxtServerInit action is called in universal mode on the sever ... data and the request will not need to be made again...
Read more >NuxtServerInit not working on Vuex module mode - Nuxt.js ...
js]." posts.js export const actions = { // This isn't called unless it is "chained" nuxtServerInit(vuexContext, context) { ...
Read more >Nuxt Lifecycle
nuxtServerInit. Vuex action that is called only on server-side to pre-populate the store; First argument is the Vuex context, second argument is the...
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 Free
Top 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
@F145h Thanks.The issue was occurred as you said. I changed the mode from ‘spa’ to “Universal” in nuxt.config.js. The problem was solved.
@iloyos , I think your problem comes from the config file (nuxt.config.js):
=> Doc : https://nuxtjs.org/guides/configuration-glossary/configuration-ssr Set it to true and that will solve your problem.