Handle unsuccessful statuses

This commit is contained in:
Ilya Ig. Petrov 2017-06-01 10:28:21 -07:00
parent 739de3d4eb
commit 0a8aaea75b

View File

@ -83,6 +83,10 @@ export default function getApp(theState) {
const [comments, etag] = await fetch( const [comments, etag] = await fetch(
ghUrl, ghUrl,
params params
).then(
(res) => !( res.status >= 200 && res.status < 300 || res.status === 304 )
? Promise.reject(new Error(`Полечен ответ с неудачным кодом ${res.status}.`))
: res
).then( ).then(
(res) => Promise.all([ (res) => Promise.all([
res.status !== 304 ? res.json() : false, res.status !== 304 ? res.json() : false,