Trying to use vue-resource but i am etting the error described in the title. The code below is in utils section called network.js
:
import VueResource from 'vue-resource'
const getConfig = () =>{
console.log('its working');
// GET /someUrl
this.$http.get('https://fdsdfsdf-685a-45ed-8665-9847e0dbce0d.mock.pstmn.io/getConfig')
.then(response => {
// get body data
this.config = response.body;
}, response => {
// error callback
});
};
//Export login so other classes can use it
export{
getConfig
}
And this the code where it gets called. It exists in one of my routes called Admin.vue
:
<template>
<div class="admin">
<h1>This is admin page area</h1>
<p>This is the data: {{this.config}}</p>
</div>
</template>
<script>
import{getConfig} from "../utils/network";
export default{
data: function () {
return {
config: [{}]
}
},
created:function(){
getConfig();
}
}
</script>
I am using it as they describe in the example i am not really sure what i am missing?