We can configure the plugin with an options parameter:
- Edit the install method to add this parameter after Vue:
export default {
install (Vue, options) {
console.log('Installed!', options)
},
}
We can now add a configuration object to the Vue.use() method in the main.js file.
- Let's add a baseUrl property to the configuration:
Vue.use(VueFetch, {
baseUrl: 'http://localhost:3000/',
})
You should now see the options object in the browser console.
- Store baseUrl into a variable so we can use it later:
let baseUrl
export default {
install (Vue, options) {
console.log('Installed!', options)
baseUrl = options.baseUrl
},
}