mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-15 13:36:35 +02:00
Ignore non-JSON error payload
This commit is contained in:
@ -29,10 +29,14 @@ export function useAPIPost(url) {
|
||||
});
|
||||
dispatch({ type: API_ACTIONS.SUCCESS, payload: result.data });
|
||||
} catch (error) {
|
||||
let payload = "An unknown error occurred";
|
||||
if (error.response.headers["content-type"] === "application/json") {
|
||||
payload = error.response.data;
|
||||
}
|
||||
dispatch({
|
||||
type: API_ACTIONS.FAILURE,
|
||||
payload: error.response.data,
|
||||
status: error.response.status,
|
||||
payload,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user