Loading js/fetchUtility.js +6 −5 Original line number Diff line number Diff line Loading @@ -6,9 +6,6 @@ * @return {object} The parsed JSON from the request */ function parseJSON(response) { if (response.status === 204 || response.status === 205) { return null; } return response.json(); } Loading @@ -20,7 +17,7 @@ function parseJSON(response) { * @return {object|undefined} Returns either the response, or throws an error */ function checkStatus(response) { if (response.status >= 200 && response.status < 300) { if (response.ok) { return response; } Loading @@ -42,6 +39,10 @@ function checkStatus(response) { function request(url, options) { return fetch(url, options) .then(checkStatus) .then(parseJSON); .then(parseJSON) .catch((error) => { console.log(error); }) } Loading
js/fetchUtility.js +6 −5 Original line number Diff line number Diff line Loading @@ -6,9 +6,6 @@ * @return {object} The parsed JSON from the request */ function parseJSON(response) { if (response.status === 204 || response.status === 205) { return null; } return response.json(); } Loading @@ -20,7 +17,7 @@ function parseJSON(response) { * @return {object|undefined} Returns either the response, or throws an error */ function checkStatus(response) { if (response.status >= 200 && response.status < 300) { if (response.ok) { return response; } Loading @@ -42,6 +39,10 @@ function checkStatus(response) { function request(url, options) { return fetch(url, options) .then(checkStatus) .then(parseJSON); .then(parseJSON) .catch((error) => { console.log(error); }) }