Show error message when visit profile page of invalid user

This commit is contained in:
taehoon 2019-02-21 13:32:47 -05:00
parent d5348c13ff
commit e687b58091
5 changed files with 19 additions and 3 deletions

View file

@ -244,6 +244,12 @@ const denyUser = ({id, credentials}) => {
const fetchUser = ({id, credentials}) => {
let url = `${USER_URL}?user_id=${id}`
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => {
if (!data.ok) {
throw Error(data.statusText)
}
return data
})
.then((data) => data.json())
.then((data) => parseUser(data))
}