mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-11-03 23:00:31 +01:00 
			
		
		
		
	Add timout handling.
This commit is contained in:
		@@ -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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user