I want to set custom header in vue-cli.
The version of vue is 2.5.2.
I tried in main.js:
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
Vue.http.headers.common['Cache-Control'] = 'no-cache, no-store, must-revalidate'
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
But it returns:
Uncaught TypeError: Cannot read property 'headers' of undefined
I think you would need to install vue-resource or vue-axios library to make this work and make REST calls.
Please install and try again.
https://github.com/pagekit/vue-resource
https://github.com/imcvampire/vue-axios
I hope this helps.