繁体   English   中英

axios.put 里面的 axios.get

[英]Axios.put inside Axios.get

我想更新状态,但是当我想执行“放置”时,它不起作用,因为 axios.put 中的 axios 未定义。 你能帮我吗。

getAbsencesByRequestId(reqId) {
    axios.get(REQUESTID_URL + reqId).then(response => {
        this.collaboId = response.data[0].collabId; 
        this.beginDate = response.data[0].startDate;
        this.finishDate = response.data[0].endDate;
        this.reason = response.data[0].type;
    }, (error) => {
        console.log(error.response.status)
    }) axios.put(REQUEST_URL + reqId, {
        collabId: this.collaboId,
        startDate: this.beginDate,
        endDate: this.finishDate,
        status: 'VALIDATED',
        type: this.reason
    })
},

您应该正确管理您的请求顺序

axios.get(url /*optional payload and headers*/).then((getResponse) => {
  //do GET stuff with response
}).then(() => {
  //do PUT call
  axios.put(url, /*optional payload and headers*/).then((putResponse) => {
    //do PUT stuff with response
  })
}).catch((e) => {
  //handle the error
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM