Commit 3998f765 authored by tom's avatar tom

limit retries for user profile

parent 36b5639f
......@@ -4,8 +4,25 @@ import type { UserInfo } from 'types/api/account';
import fetch from 'lib/client/fetch';
interface Error {
error?: {
status?: number;
statusText?: string;
};
}
export default function useFetchProfileInfo() {
return useQuery<unknown, unknown, UserInfo>([ 'profile' ], async() => {
return useQuery<unknown, Error, UserInfo>([ 'profile' ], async() => {
return fetch('/api/account/profile');
}, { refetchOnMount: false });
}, {
refetchOnMount: false,
retry: (failureCount, error) => {
if (error?.error?.status === 401) {
// for unauthorized users don't do retry
return false;
}
return failureCount < 2;
},
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment