Skip to content

Commit

Permalink
fix : add await to logoutRedirection
Browse files Browse the repository at this point in the history
  • Loading branch information
abdou6666 committed Jan 22, 2025
1 parent 57ffe7b commit 798d126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frontend/src/hooks/entities/auth-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const useLogout = (

return await apiClient.logout();
},
onSuccess: () => {
onSuccess: async () => {
queryClient.removeQueries([CURRENT_USER_KEY]);
logoutRedirection();
await logoutRedirection();
},
});
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/useApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export const useAxiosInstance = () => {
// Response Interceptor
instance.interceptors.response.use(
(resp) => resp,
(error) => {
async (error) => {
if (!error.response) {
// Optionally redirect to an error page or show a notification
toast.error(t("message.network_error"));

return Promise.reject(new Error("Network error"));
}
if (error.response.status === 401) {
logoutRedirection(true);
await logoutRedirection(true);
}

return Promise.reject(error.response.data);
Expand Down

0 comments on commit 798d126

Please sign in to comment.