setupaxios global vuejs 3

Solutions on MaxInterview for setupaxios global vuejs 3 by the best coders in the world

showing results for - "setupaxios global vuejs 3"
Lylia
03 Sep 2019
1import axios from 'axios';
2
3// Provide style
4const app = Vue.createApp(App);
5app.provide('$axios', axios);  
6
7// Composition style
8const { inject } = Vue;
9setup() {
10  const $axios = inject('$axios');
11}
12
13// Options style
14inject: ['$axios'],
15  
16// setup global axios
17import axios from 'axios';
18
19const app = Vue.createApp(App);
20app.config.globalProperties.$axios = axios;
21
22// access this axios
23this.$axios