mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +01:00
Add timout handling.
This commit is contained in:
parent
0f5b35a3ba
commit
b831d664a9
|
@ -42,7 +42,7 @@ function createAPIHook(method) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: API_ACTIONS.FAILURE,
|
type: API_ACTIONS.FAILURE,
|
||||||
payload: getErrorMessage(error),
|
payload: getErrorMessage(error),
|
||||||
status: error.response.status,
|
status: error.response && error.response.status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [url, contentType]);
|
}, [url, contentType]);
|
||||||
|
|
|
@ -53,9 +53,12 @@ function getCookie(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getErrorMessage(error) {
|
export function getErrorMessage(error) {
|
||||||
let payload = "An unknown error occurred";
|
let payload = _("An unknown error occurred.");
|
||||||
if (error.response.headers["content-type"] === "application/json") {
|
if (error.response && error.response.headers["content-type"] === "application/json") {
|
||||||
payload = error.response.data;
|
payload = error.response.data;
|
||||||
}
|
}
|
||||||
|
if (error.code === "ECONNABORTED") {
|
||||||
|
payload = _("Timeout error occurred.");
|
||||||
|
}
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user