[Vuejs]-Node vue require library for use in component

0👍

You must require(‘axios’) in every component you want to use it.

But the way I prefer, is to set up Vue.prototype.$http with axios.
So, before declaring your Vue app, you declare

Vue.prototype.$http = axios

then axios will be available in any of your components without the need of importing it.

mounted: function() {
    this.$http.get('/whatever').then(whatever)
    ...
}

Source: vue-resource retirement

Leave a comment