Static GitHub Issues

[142] how call server related methods/functions in nuxtServerInit

prev: Very bad flash of unstyled content when trying the starter template
next: How to include Yandex.Metrika counter code on Nuxt.js app?

Is it possible to do something like this?

actions: {
        nuxtServerInit({ commit }, { req }) {
            const fs = require('fs');
            const content = fs.readFileSync(__dirname + '../package.json');
            console.log('secret');
            commit('SET_USER', content);
        }
    }
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c120">#c120</a>)</em></sub></div>