[Vuejs]-VUE.js problem value reurned by AJAX call asyncrously

0👍

axios.get return Promise as async response, so you must handle this correctly:


fetchData2( id ) {
  this.getGranParent( id ).then(parent => this.fetchData( parent ))
},
getGranParent( id ) {
  return axios.get('http://localhost:9002/get_granparent', {params: { id: id }})
    .then( response => {
      this.granParentId = response.data
      return response.data
    })      
}

Leave a comment