Axios.Delete()没有执行,然后没有catch块

时间:2017-10-14 09:02:40

标签: c# reactjs axios

我有反应+ redux客户端和C#API。我目前正在尝试在反应中实现删除方法。

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);
    }

当我在chrome中调试它时,我可以看到然后并且不执行catch块。该请求未被我的C#控制器捕获。

当我向Postman尝试相同的请求时,通常会在API中捕获该请求。

即使我将url作为硬编码字符串,这也不起作用 axios.delete('http://localhost:1467/v1/patients/11')

你能告诉我发生了什么(没有发生)吗?

注意:get方法正常运行

1 个答案:

答案 0 :(得分:1)

非常感谢我的朋友,我发布了工作解决方案。我错过了默认标头。 Postman是通过插入默认标题,df.groupby('family')['score'].median().filter(lambda x: x>x.median)我必须自己定义它。

axios
相关问题