Add responce checking to query util

This commit is contained in:
Stanislav Romanov 2022-09-11 12:44:49 +03:00
parent 31e8c1cb6d
commit da91687160

View file

@ -15,5 +15,11 @@ export default function query(path, options = {}) {
Object.assign(options, { headers })
);
return fetch(req).then((res) => res.json());
return fetch(req).then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error('Network response was not OK');
}
});
}