nuxt-community / moment-module

Efficient Moment.js integration for Nuxt
MIT License
195 stars 12 forks source link

undefined in middleware context #5

Closed arnasziedavicius closed 5 years ago

arnasziedavicius commented 6 years ago

When in middleware context, app, $moment seems to be undefined. When called in component, however, there seems to be no problem.

nuxt.config.js setup:

module.exports = {
  /*
  ** Modules
  */
  modules: [
    '@nuxtjs/moment',
  ],
  /*
  ** Moment
  */
  moment: {
    locales: ['de'],
    plugin: true,
  },
  /*
  ** Router
  */
  router: {
    middleware: ['test'],
  },
};

Middleware (test.js) code where $moment is undefined:

export default function (context) {
  console.log(context.app.$moment);
}

When does $moment get injected to Vue context and is there something I'm missing?