Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
fix(web): 404 error in console on avatar not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Guusvanmeerveld committed Nov 9, 2022
1 parent 0814829 commit ca1a898
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/interfaces/http.d.ts
Expand Up @@ -16,7 +16,7 @@ export default interface HttpClient {
refresh: (refreshToken: string) => Promise<LoginResponse>;
getBoxes: (token?: string) => Promise<BoxResponse[]>;
getPublicOAuthTokens: () => Promise<PublicTokensResponse>;
getAvatar: (address?: string) => Promise<string>;
getAvatar: (address?: string) => Promise<string | undefined>;
getBox: (
boxID: string,
pageParam: number,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/utils/hooks/useAvatar.ts
Expand Up @@ -35,7 +35,7 @@ export default function useAvatar(
const blacklisted = !!noAvatar;

const { data, isLoading, error } = useQuery<
string,
string | undefined,
AxiosError<ErrorResponse>
>(
["avatar", email],
Expand Down
10 changes: 7 additions & 3 deletions apps/web/src/utils/hooks/useFetch.ts
Expand Up @@ -153,11 +153,15 @@ const useHttpClient = (): HttpClient => {
return data;
},
async getAvatar(address) {
const { data } = await instance.get("/avatar", {
params: { address }
const res = await instance.get("/avatar", {
params: { address },
validateStatus: (status) =>
(status >= 200 && status < 300) || status == 404
});

return data;
if (res.status == 404) return;

return res?.data;
}
};
};
Expand Down

0 comments on commit ca1a898

Please sign in to comment.