Javascript Axios忽略重播
我有以下代码:Javascript Axios忽略重播,javascript,axios,response,Javascript,Axios,Response,我有以下代码: request(options).then( ( res ) => { if(res.data.jobStatus === "ACTIVE"){ this.setState({ jobId: res.data.jobId, }) alert("Calculation started: " + this.state.activeCalcDates ); } }) 据我所知,.t
request(options).then( ( res ) => {
if(res.data.jobStatus === "ACTIVE"){
this.setState({
jobId: res.data.jobId,
})
alert("Calculation started: " + this.state.activeCalcDates );
}
})
据我所知,.then()
应该等待axios函数(请求)
在运行之前实际完成。然后()
但是,我的代码将被吹穿,jobId
将保持undefined
,在查询后中断逻辑
我知道服务器的每个响应都包含res.data.jobStatus==“ACTIVE”
但是js很少承认这一点,而且大多只是忽略jobStatus
,让客户端挂起最后一个被动状态
2 < 202
2 < Content-Type: application/json
{
"status" : "BUSY",
"currentJob" : {
"id" : 1,
"jobId" : "xxxx-yyyy-zzzz",
"jobStatus" : "ACTIVE"
}
}
2<202
2<内容类型:应用程序/json
{
“状态”:“忙”,
“当前作业”:{
“id”:1,
“作业ID”:“xxxx yyyy ZZZ”,
“作业状态”:“活动”
}
}
使用res.data.currentJob.jobStatus
更改res.data.jobStatus
。还有res.data.jobId
和res.data.currentJob.jobId