nuxt-community / axios-module

Secure and easy axios integration for Nuxt 2
https://axios.nuxtjs.org
MIT License
1.19k stars 246 forks source link

Using injected axios instance in asyncData method #528

Closed VividLemon closed 3 years ago

VividLemon commented 3 years ago

I've been trying to access my injected method named api -- inside the asyncData / fetch methods of nuxt. Whatever I do does not seem to work. I cannot use this.$api, or $api. I cannot use this.api or api... and also cannot put asyncData({ $api }) without $ or without {}... You get the idea, I've tried basically all variations of trying to access the created instance. How can I get access to the axios instance inside of the fetch/asyncData methods? Thanks!

VividLemon commented 3 years ago

I see. There was an error inside the $get methods. Obviously it's my luck that 2 minutes after I submit the error, I fix it myself