首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Axios.get内部的Axios.put

Axios.get内部的Axios.put
EN

Stack Overflow用户
提问于 2018-05-31 23:34:28
回答 1查看 3.2K关注 0票数 3

我想要更新状态,但当我想做'put‘时,它不工作,因为axios.put中的axios没有定义。你能帮帮我吗?

代码语言:javascript
复制
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
    })
},
EN

回答 1

Stack Overflow用户

发布于 2018-06-01 07:10:34

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

代码语言:javascript
复制
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
})
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50627968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档