Skip to content

Commit 19d5591

Browse files
committed
fix: handle 204 response
Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent ac83c56 commit 19d5591

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/service/AvatarService.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,18 @@ export const fetchAvatarUrl = (email) => {
1717
})
1818

1919
return Axios.get(url, { adapter: 'fetch', fetchOptions: { priority: 'low' } })
20-
.then((resp) => resp.data)
21-
.then((avatar) => {
22-
if (avatar.isExternal) {
20+
.then(res => {
21+
if (res.status === 204) {
22+
return undefined
23+
}
24+
25+
if (res.data.isExternal) {
2326
return generateUrl('/apps/mail/api/avatars/image/{email}', {
2427
email,
2528
})
26-
} else {
27-
return avatar.url
28-
}
29-
})
30-
.catch((err) => {
31-
if (err.response.status === 404) {
32-
return undefined
3329
}
3430

35-
return Promise.reject(err)
31+
return res.data.url
3632
})
3733
}
3834

0 commit comments

Comments
 (0)