Client - cancel duplicate api calls

This commit is contained in:
Sam
2022-09-19 10:53:31 +02:00
parent 6982f5320a
commit a040b0c845
5 changed files with 73 additions and 3 deletions

View File

@ -28,7 +28,12 @@ export const handleError = (
error: AxiosError | null,
msg = 'UNKNOWN'
): void => {
// if stored token is blacklisted
// if request is cancelled, no error to display
if (error && error.message === 'canceled') {
return
}
// if stored token is blacklisted, disconnect user
if (
error?.response?.status === 401 &&
error.response.data.error === 'invalid_token'
@ -37,6 +42,7 @@ export const handleError = (
context.dispatch(AUTH_USER_STORE.ACTIONS.CHECK_AUTH_USER)
return
}
const errorMessages = !error
? msg
: error.response