Setting Baseurl For Axios In Vue Js Sends Out Request
In my app I use Axios to handle my API-requests. In main.js I have set the baseUrl. Without me making a request it makes a request on its own just by setting the baseUrl, so always
Solution 1:
I have tried to replicate your problem but it works fine to me, how are you implementing Axios? Which version are you using?
[EDIT] Suggested solution
Using this as Nuxt plugin
constaxios= require('axios')
module.exports = axios.create({
baseURL: 'domain.nl/path/to/my/api'
})
You can find more info in the comments below
Solution 2:
importVuefrom"vue";
importAxiosfrom"axios";
Vue.prototype.$http = Axios;
Axios.defaults.headers.common = {'X-Requested-With': 'XMLHttpRequest'}
Axios.defaults.baseURL = (process.env.API_PATH !== 'production') ? 'http://localhost:8000/api/' : '';
Ensure baseURL not baseUrl
Post a Comment for "Setting Baseurl For Axios In Vue Js Sends Out Request"