yamlful
yamlful copied to clipboard
Cannot read property 'get' of undefined
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)
}
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 yes, indeed, I need to add a note about this to the README :)
@liamjgm actually, yamlful-nuxt automatically includes @nuxtjs/axios module.
@galvez perfect, thank you