0
我剛開始着眼於反應設計狀態+動作。目前我專注於API調用。我創建了一個apimanager,這是我的要求:如何從reactjs/redux中止apicall?
axios.get('http://localhost:3000/0')
.then(response => {
store.dispatch(getDataSuccess(response.data));
return response;
}).catch(function (error) {
console.log('error', error);
store.dispatch(getDataError(error));
return error;
});
在此刻,我的404而不是超時捕獲錯誤。我如何在反應js/redux/axios中捕捉超時?
不愛可信給你一個方法來處理超時錯誤?一旦你已經發現了超時錯誤(我猜測「.then()」的第二個參數),那麼你可以發送你的timeout_handle動作。 – iamnat