我有以下代码,使API调用和基于HTTP响应,它调度我的redux减速器中的某些操作。处理失败的API调用提取
问题是,如果API调用失败,它将在控制台中显示它,即使处理不成功调用的代码部分执行正常。我怎样才能防止呢?我已经处理了不成功的API调用,因此在控制台中什么也不显示。
export const someApiCall =() => {
return (dispatch) => fetch('/api/somefunction', fetchOptionsGet())
.then((response) => {
if(response.ok) {
// Success. Dispatch some actions
} else {
// Failed call. Dispatch some other actions
}
})
}