0๐
Use axios.create function
You can give there base-url param and import axios as a vue plugin globally
0๐
I made axios global in the main.js file. As per the documentation, config defaults can be specified that will be applied to every request.
import Vue from 'vue'
import router from './routes'
import axios from 'axios';
axios.defaults.baseURL = 'http://localhost:3000';
window.axios = axios;
new Vue({
el: '#app',
router
})
Source:stackexchange.com