Add responce checking to query util
This commit is contained in:
parent
31e8c1cb6d
commit
da91687160
1 changed files with 7 additions and 1 deletions
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue