I built a vueJS component, that does an axios request when mounted. I want to populate different input fields with the response data.
mounted: function(){
this.$root.$on('getmydata',(ID) => {
this.ID= ID;
axios.get('/edit/'+ID).then(response => this.details= response.data);
this.InputField1 = this.details.mytext;
});
But this way this.InputField1 will be 'undefined' (console.log). But if I do it like this:
axios.get('/edit/'+ID).then(response => this.InputField1= response.data.mytext);
the data is there (populated in the field).
My Question: I want to populate multiple fields with the response data. How can I use the response.data outside of axios.get().then(..)?