Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

478
Vistas
$axios unavailable in NuxtJS plugin registered via module

I have my own NuxtJS module which registeres my own plugin like so:

import path from 'path'

export default function (moduleOptions) {
  const { nuxt } = this

  this.addPlugin({
    src: path.resolve(__dirname, 'src/plugins/auth.js'),
    options: Object.assign({}, nuxt.options.pauth, moduleOptions)
  })
}

The problem shows up when I try to access $axios within plugin registered via module. Does anyone know how to make it work?

export default({ $axios, store }, inject) => {
  store.registerModule('auth', authModule, { preserveState: !!store.hasModule('auth') })
  inject('auth', new AuthService(store, '<%= JSON.stringify(options) %>'))
  //
  //
  //
  // console.log(app.$axios, 'robert')


  // $axios.onRequest(config => {
  //   console.log('config')
  // })
  // app.router.beforeEach(async (to, from, next) => {
  //   await store.restored
  //   next()
  // })
}

So $axios is undefined but store is there. The context when logged in console or normal plugin defined outside of my module has access to $axios.

It is clearly to do with order and timing. Does anyone know how to deal with that? My plugin lives in my module.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda