agraboso / agraboso/redux-api-middleware
How to detect timeout or refused connection?
- Vorherrschende Sprache
- JavaScript
- Sterne
- 1.5k
- Forks
- 190
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I have something like this:
```
//...
return {
[CALL_API]: {
endpoint,
method,
types: [
types.API_POST_CREDENTIALS_REQUEST,
{
type: types.API_POST_CREDENTIALS_SUCCESS,
payload: (action, state, res) => apiUpdateSuccess(action, state, res)
},
{
type: types.API_POST_CREDENTIALS_FAILURE,
payload: (action, state, res) => apiUpdateFailure(action, state, res)
}
],
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(payload)
}
};
//...
function apiUpdateSuccess(action, state, res) {
return getJSON(res).then((data) => {
return data;
});
}
function apiUpdateFailure(action, state, res) {
return getJSON(res).then((data) => {
return data;
});
}
```
But when the API is offline or a request times out, neither apiUpdateSuccess nor apiUpdateFailure is fired. What would be the best practice to detect timeout and offline API?
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.