How can I access a property from a method inside another method in VUEJS? In this example, I need an "mb_id" from fetchMA method in order to use it in fetchMB args.
export default {
name: 'details',
data () {
return {
mA: {},
mB: ''
}
},
methods: {
fetchMA(id){
this.$http.get('apiurl/' + id )
.then(function(response){
this.mA = response.body;
});
},
fetchMB(id){
this.$http.get('apiurl/' + id )
.then(function(response){
this.mB = response.body;
});
}
},
created: function(){
this.fetchMA(this.$route.params.id);
this.fetchMB(this.mA.mb_id);
}
}
If I hard code a digit inside the created, such as - this.fetchMB(10); this fetches what I need, but for obvious reasons this is not feasible.
Thank you all,
-S
mAan array or an object that has anmb_idproperty?