diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index d8616538..4735e0cc 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -563,11 +563,20 @@ const fetchTimeline = ({ }) return data }) - .then((data) => data.json()) .then((data) => { - if (data.error || data.errors) { + if (status >= 500) { + return { errors: ['Server error'] } + } + return data.json() + }) + .then((data) => { + if (status >= 400) { + console.log(data.error, data.errors) data.status = status data.statusText = statusText + if (data.error) { + data.errors = [data.error] + } return data } return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination } diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 9c922739..921df3ed 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -49,7 +49,7 @@ const fetchAndUpdate = ({ return apiService.fetchTimeline(args) .then(response => { - if (response.error || response.errors) { + if (response.errors) { throw new Error(`${response.status} ${response.statusText}`) }