0
I am using Axios in one of my projects with Vuejs, my doubt is directly linked to the global import form of the plugin. Currently I’m doing so:
Create a /plugin/Axios.js file with this code:
import Vue from 'vue'
import Axios from 'axios'
Axios.defaults.baseURL = 'https://minha-api/'
Vue.use({
install(Vue) {
Vue.prototype.$http = Axios
}
})
And in main.js I import the above file.
I even thought about ignoring the /plugins/Axios.js and making the import directory in main.js in this way:
...
import Axios from 'axios'
Axios.defaults.baseURL = 'https://api.cartolafc.globo.com/'
Vue.prototype.$http = Axios
....
If possible I would still like to understand what that would be:
Vue.use({
install(Vue) {
How would this use as Singleton?
– Fábio Jânio