mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-24 00:01:36 +01:00
Ignore non-JSON error payload
This commit is contained in:
parent
9641fbcb50
commit
44e45499c6
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "0.1.0-beta.5",
|
"version": "0.1.0-beta.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "0.1.0-beta.5",
|
"version": "0.1.0-beta.6",
|
||||||
"description": "Set of components and utils for Foris and its plugins.",
|
"description": "Set of components and utils for Foris and its plugins.",
|
||||||
"author": "CZ.NIC, z.s.p.o.",
|
"author": "CZ.NIC, z.s.p.o.",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -29,10 +29,14 @@ export function useAPIPost(url) {
|
||||||
});
|
});
|
||||||
dispatch({ type: API_ACTIONS.SUCCESS, payload: result.data });
|
dispatch({ type: API_ACTIONS.SUCCESS, payload: result.data });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
let payload = "An unknown error occurred";
|
||||||
|
if (error.response.headers["content-type"] === "application/json") {
|
||||||
|
payload = error.response.data;
|
||||||
|
}
|
||||||
dispatch({
|
dispatch({
|
||||||
type: API_ACTIONS.FAILURE,
|
type: API_ACTIONS.FAILURE,
|
||||||
payload: error.response.data,
|
|
||||||
status: error.response.status,
|
status: error.response.status,
|
||||||
|
payload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user