I created a new project using:
vue create hello-world
Generating a new project that includes the HelloWorld.vue
, app.vue
, main.js
(etc ...) files.
Now I install Axios by following the docs Npm vue-axios:
npm install --save axios vue-axios
I import Axios in the main.js
file:
import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
And now I run into a problem that I don't understand. The VueAxios
docs say you simply use it like so:
const app = Vue.createApp(...)
app.use(VueAxios, axios)
But the way app
is created in Vue 3 is different. I think this is where the problem comes from:
createApp(App).mount('#app')
So, how do I correctly import axios?
axios
where needed (including in the Composition API) instead of usingvue-axios
. – Trunnion