1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-07-02 20:30:27 +00:00

Merge branch 'reforis-125-ignore-non-json-errors' into 'dev'

Ignore non-JSON error payload

See merge request turris/reforis/foris-js!12
This commit is contained in:
Maciej Lenartowicz 2019-09-30 12:58:41 +00:00
commit 800dedbcfd
3 changed files with 7 additions and 3 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "foris",
"version": "0.1.0-beta.5",
"version": "0.1.0-beta.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"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.",
"author": "CZ.NIC, z.s.p.o.",
"repository": {

View File

@ -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,
});
}
};