Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

471
Views
$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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!