Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
e60f0513
Commit
e60f0513
authored
Sep 14, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common retry function
parent
881fd2bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
useFetchProfileInfo.tsx
lib/hooks/useFetchProfileInfo.tsx
+0
-8
_app.tsx
pages/_app.tsx
+10
-0
No files found.
lib/hooks/useFetchProfileInfo.tsx
View file @
e60f0513
...
@@ -18,13 +18,5 @@ export default function useFetchProfileInfo() {
...
@@ -18,13 +18,5 @@ export default function useFetchProfileInfo() {
return
fetch
(
'
/api/account/profile
'
);
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
;
},
});
});
}
}
pages/_app.tsx
View file @
e60f0513
...
@@ -4,6 +4,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
...
@@ -4,6 +4,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import
type
{
AppProps
}
from
'
next/app
'
;
import
type
{
AppProps
}
from
'
next/app
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
theme
from
'
theme
'
;
import
theme
from
'
theme
'
;
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
...
@@ -11,6 +12,15 @@ function MyApp({ Component, pageProps }: AppProps) {
...
@@ -11,6 +12,15 @@ function MyApp({ Component, pageProps }: AppProps) {
defaultOptions
:
{
defaultOptions
:
{
queries
:
{
queries
:
{
refetchOnWindowFocus
:
false
,
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
;
},
},
},
},
},
}));
}));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment