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