I have a requirement where in app startup , we have to make an Axios call and get some value..that values should be available to all application... they are some meta data's in server side and should be fetched only once during the app initialization... I have approached it by defining a mixin inside the plugin and hope to get the values inside the components..In that case , where should i do the axios call? inside the mixin or plugin?
import Vue from 'vue'
import Axios from 'axios'
const StudentCoinPlugin = {
install (Vue, options) {
Axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => {
Vue.mixin({
mounted () {
console.log('Mounted!Plugin----------')
},
data: function () {
return {
globalReadOnlyProperty: this.response.data.time.updated
}
}
})
}
)
}
}
Is it the right thing to do? Or what is the best approach to read some values and get it in the global scope when application starts?