From da916871603b94ebdbad6e3acda8578a6fb6ffe9 Mon Sep 17 00:00:00 2001 From: Stanislav Romanov Date: Sun, 11 Sep 2022 12:44:49 +0300 Subject: [PATCH] Add responce checking to query util --- app/utils/query.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/utils/query.js b/app/utils/query.js index af752b6..99bcb98 100644 --- a/app/utils/query.js +++ b/app/utils/query.js @@ -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'); + } + }); }