First, the axios setup was carried out according to the document nuxtjs as follows.
nuxt.config.js
modules: [
'@nuxtjs/axios',
],
axios: {
// extra config e.g
// BaseURL: 'https://link-to-API'
}
And I tried to build a store and approach axios in action, but I met undefined.
user.ts
import { Module, VuexAction } from 'nuxt-property-decorator';
@Module({
name: 'user',
stateFactory: true,
namespaced: true
})
export default class User extends VuexModule {
@VuexAction({ rawError: true })
private async axiosSideInfo({}) {
this.$axios < ---------------- undefined
.post( ... )
)
}
}
Something's wrong...
{
actions: {
async getIP ({ commit }) {
const ip = await this.$axios.$get('http://icanhazip.com')
commit('SET_IP', ip)
}
}
}