My axios configuration looks like this:
const configAxios = {
baseURL: 'http://127.0.0.1:8000/api',
timeout: 30000,
};
Vue.prototype.$axios = axios.create(configAxios)
When making a call inside my component, I use the following syntax:
this.$axios.get('items').then()..
Although the above code works fine, I'm looking to dynamically change the baseURL
without impacting the global base URL. This way, I can conveniently use it in my component without specifying the API endpoint every time.
I've attempted the following approach:
this.$axios.baseURL = "http://127.0.0.1:8000";
this.$axios.get().. //still uses the api endpoint
What would be the best way to achieve this?