Reputation: 4220
I would like to be able the same axios
instance used in the auth module (https://auth.nuxtjs.org/) in a javascript module where I make my API calls
I have the following
const BASE_URL = 'job';
export default {
getJobs(params?: Filter) {
return axios.get(BASE_URL, { params });
},
getJob(slug: string, params?: Filter) {
return axios.get(`${BASE_URL}/${slug}`, { params });
}
}
I would like to be able to use the same $axios instance inside of this js module. Something like:
const BASE_URL = 'job';
export default {
getJobs(params?: Filter) {
return this.$axios.get(BASE_URL, { params });
},
getJob(slug: string, params?: Filter) {
return this.$axios.get(`${BASE_URL}/${slug}`, { params });
}
}
Is this possible?
Upvotes: 2
Views: 722
Reputation: 848
Yes it is possible to get axios instance using this.$axios
in Nuxt.js
Upvotes: 1