setupaxios global vuejs 3
import axios from 'axios';
// Provide style
const app = Vue.createApp(App);
app.provide('$axios', axios);
// Composition style
const { inject } = Vue;
setup() {
const $axios = inject('$axios');
}
// Options style
inject: ['$axios'],
// setup global axios
import axios from 'axios';
const app = Vue.createApp(App);
app.config.globalProperties.$axios = axios;
// access this axios
this.$axios