[Vuejs]-How to use the same javascript file in a Vue file and a HTML file?

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
})

Leave a comment