I am currently utilizing Vue.js 2.3.3, Vue Resource 1.3.3, and Vue Router 2.5.3 in my project while trying to configure Vue-Auth. Unfortunately, I keep encountering a console error message that reads
auth.js?b7de:487 Error (@websanova/vue-auth): vue-resource.1.x.js: Vue.http must be set.
. Even after setting Vue.http
in the main.js file, vue-resource does not seem to recognize it for some unknown reason.
Main.js:
import Vue from 'vue'
import Actions from 'actions'
import App from './App'
Vue.use(Actions, {
locales: ['en', 'zh', 'fr']
})
Vue.http.options.root = 'https://api.example.com'
new Vue({
render: h => h(App),
watch: {
lang: function (val) {
Vue.config.lang = val
}
}
}).$mount('#app')
Actions/index.js
import VueResource from 'vue-resource'
import Router from 'actions/router'
import I18n from 'actions/i18n'
export default {
install (Vue, options) {
Vue.use(Router)
Vue.use(I18n, options.locales)
Vue.use(require('@websanova/vue-auth'), {
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x'),
auth: require('@websanova/vue-auth/drivers/auth/bearer'),
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x')
})
}
}
Furthermore, adding Vue.use(VueResource)
to actions/index.js directly below Vue.use(Router)
results in a new error:
Error (@websanova/vue-auth): vue-router.2.x.js : Vue.router must be set.
Alternatively, if I move
Vue.http.options.root = 'https://api.example.com'
right below the import statements, a different error occurs: Uncaught TypeError: Cannot read property 'options' of undefined