0👍
✅
After debugging your app i found that you re-defied (re-imported) Vue
on your dailypractice.vue
component also VueAxios
/ axios
… if you are going to use vueResource
you don’t need axios
(i reccomend axios as a Vue dev )
// dailypractice.vue
import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)
Just remove the previous code from your dailypractice
component and also axios
/ VueAxios
from your project (axios.js file) and your app will work fine.
0👍
You need to define this.$http
root :
import Vue from 'vue';
import router from './router';
import store from './store';
import App from './App.vue';
import VueResource from 'vue-resource';
Vue.use(VueResource);
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
Vue.http.options.root = 'http://api.iqube.org.in/';
then on your mounted and wherever you include this.$http
add the route that you want to target … like this :
mounted () {
this.$http.get('/questions').then(response => {
this.questionData = response.body;
console.log(response.body)
}, error => {
});
}
0👍
Don’t forget import axios and use it at main.js .
import axios from 'axios'
Vue.use(axios)
Source:stackexchange.com