0👍
Have you call that getData
method? It doesn’t call automatically by Vue. You can use mounted
or created
lifecycle hooks to call that method. Somekind like this,
methods: {
getData: function(){
axios.get('/my/url')
.then((response)=>{
this.myObj = response.data;
console.log("Response data: " , response.data); //**A**
console.log("'This data:' " , this.data.purchaseorder); //**B**
})
.catch((error)=>{
//ERROR
});
}
},
mounted () {
this.getData()
}
- [Vuejs]-Return response from VUEX actions to component
- [Vuejs]-Vue @click event not working for showing modal
0👍
Change the getData
method to the following, without function
:
methods: {
getData () {
axios.get('/my/url')
.then(response => {
this.myObj = response.data;
console.log("Response data: " , response.data); //**A**
console.log("'This data:' " , this.data.purchaseorder); //**B**
})
.catch(error => {
//ERROR
});
}
}
In this case, the context of this
is bound within getData: function () { ... }
- [Vuejs]-Vue.js – How to create child component's DOM element outside of it's parent component's DOM element
- [Vuejs]-Vue.js radio button not checked by default
Source:stackexchange.com