Currently, I find myself in main.js where I am importing vue-axios
Main.js
import { createApp } from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
import App from './App.vue';
const app = createApp(App);
app.use(VueAxios, axios);
app.mount('#app');
Now, looking at App.vue
export default {
name: 'App',
setup() {
axios.get('xxxx').then((res) => {console.log(res)}); // this code is not functioning as expected
}
};
It appears that the Vue composition API setup cannot access axios. Perhaps, it should be used within App.vue like so: import axios from 'axios'
?
import axios from 'axios';
export default {
name: 'App',
setup() {
axios.get('xxxx').then((res) => {console.log(res)});
}
};
The current environment I am working in is vite