From f13f643baabf4442f3b282397afa97b1ec340884 Mon Sep 17 00:00:00 2001 From: Roberto Tonino Date: Wed, 2 Jun 2021 15:32:20 +0200 Subject: [PATCH] fix: removed blocking fetch responses if not ok --- src/utils/api.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/utils/api.js b/src/utils/api.js index 1f61d11..c8be5f7 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -6,14 +6,10 @@ export function fetchData(key, data = {}, method = 'GET') { }) return fetch(url.href, { method }) - .then(response => { - if (!response.ok) { - throw new Error('Network response was not ok') - } - return response.json() - }) + .then(response => response.json()) .catch(error => { console.error('There has been a problem with your fetch operation:', error) + return Promise.reject(error) }) }