Request and return the result package axios

axios request is an asynchronous request, I encountered a plurality of requests with the same address, parameter passing through different control returns to the desired results, and therefore, like the case as a function of package axios request, return results through the return pass come out.

But how to achieve it, the way I was used as follows:

the queryData (parameter ..) {
  was data = {
    Definition request parameter ..
  }
  return axios.post(this.url,datas).then(response=>response.data.result).catch(error => error)
},

  Where the return value in the form of promise, so using .then () Gets the value.

this.queryData(参数..).then(response=>{
        console.log(response)          
 })    

  You can get the desired value.

Guess you like

Origin www.cnblogs.com/baoziqiaodaima/p/12079656.html