Answers for "setupaxios global vuejs 3"

0

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
Posted by: Guest on March-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language