mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
common retry function
This commit is contained in:
@@ -18,13 +18,5 @@ export default function useFetchProfileInfo() {
|
||||
return fetch('/api/account/profile');
|
||||
}, {
|
||||
refetchOnMount: false,
|
||||
retry: (failureCount, error) => {
|
||||
if (error?.error?.status === 401) {
|
||||
// for unauthorized users don't do retry
|
||||
return false;
|
||||
}
|
||||
|
||||
return failureCount < 2;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
import type { AppProps } from 'next/app';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import type { ErrorType } from 'lib/hooks/useFetch';
|
||||
import theme from 'theme';
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
@@ -11,6 +12,15 @@ function MyApp({ Component, pageProps }: AppProps) {
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: false,
|
||||
retry: (failureCount, _error) => {
|
||||
const error = _error as ErrorType<{ status: number }>;
|
||||
if (error?.error?.status === 401) {
|
||||
// for unauthorized users don't do retry
|
||||
return false;
|
||||
}
|
||||
|
||||
return failureCount < 2;
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user