2
我有反应+ redux客户端和C#API。我目前正试图在反应中实现删除方法。Axios.Delete()没有执行那么既没有catch块
patients.js
deletePatient(patientId) {
debugger;
axios.delete(url + 'patients/' + patientId).then(res =>
{
this.props.dispatch(deletePatientAction(res));
})
.catch(function(error) {
console.log(JSON.stringify(error, null, 2));
});
}
PatientController.cs
[HttpDelete]
public HttpResponseMessage Delete(int id)
{
patientTasks.Delete(id);
return Request.CreateResponse(HttpStatusCode.OK);
}
,当我在铬调试它,我可以看到,那么,不执行catch块。请求没有被我的C#控制器捕获。
当我用邮递员尝试相同的请求时,请求正常被捕获到API中。
如果我把URL作为一个硬编码字符串 axios.delete('http://localhost:1467/v1/patients/11')
你能告诉我发生了什么(不会发生),这甚至不工作?
注:get方法是否正确
如果你用邮递员运行相同的请求,它工作吗? – Freez
是的,我在我的问题中告诉过它。 – pandemic
对不起,我读得太快了......你在Chrome网络督察中看到了什么? – Freez