Fixed "user.id is undefined" or something error more sane by properly handling

HTTP errors
This commit is contained in:
Henry Jameson 2018-09-17 18:55:11 +03:00
parent e53f238278
commit 03f28d3fa6
1 changed files with 8 additions and 1 deletions

View File

@ -335,7 +335,14 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&')
url += `?${queryString}`
return fetch(url, { headers: authHeaders(credentials) }).then((data) => data.json())
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => {
if (data.ok) {
return data
}
throw new Error('Error fetching timeline')
})
.then((data) => data.json())
}
const verifyCredentials = (user) => {