yamlful icon indicating copy to clipboard operation
yamlful copied to clipboard

Cannot read property 'get' of undefined

Open liamjgm opened this issue 5 years ago • 4 comments

My modules include, '@nuxtjs/axios' and 'yamlful-nuxt

But I keep getting an error "client is undefined". I put a console log in the plugin.js like below and axios is undefined.

export default (ctx, inject) => {
  console.log(ctx.$axios) // <!----- console log here is undefined ---->
  const $api = api(ctx.$axios)
  extendStore(ctx, { $api })
  ctx.$api = $api
  inject('api', $api)
}
faqs:
  - method: all
    get: /faqs
  - method: allActive
    get: /faqs?active=1
  - method: get
    get: /faqs/:id
  - method: create
    post: /faqs
  - method: update
    put: /faqs/:id
  - method: remove
    delete: /faqs/:id
async asyncData({ app, error, $api }) {
    const response = await $api.faqs.all()
    console.log(response.data)
}

liamjgm avatar Jan 25 '19 21:01 liamjgm

Found solution

In modules 'yamlful-nuxt' must come before '@nuxtjs/axios'. I don't know if it will be the same for everyone but fixed for me

liamjgm avatar Jan 25 '19 22:01 liamjgm

@liamjgm yes, indeed, I need to add a note about this to the README :)

galvez avatar Jan 26 '19 03:01 galvez

@liamjgm actually, yamlful-nuxt automatically includes @nuxtjs/axios module.

galvez avatar Jan 26 '19 03:01 galvez

@galvez perfect, thank you

liamjgm avatar Jan 26 '19 09:01 liamjgm