fix : add await to logoutRedirection

This commit is contained in:
abdou6666 2025-01-22 08:51:15 +01:00
parent 57ffe7b8c0
commit 798d126700
2 changed files with 4 additions and 4 deletions

View File

@ -62,9 +62,9 @@ export const useLogout = (
return await apiClient.logout();
},
onSuccess: () => {
onSuccess: async () => {
queryClient.removeQueries([CURRENT_USER_KEY]);
logoutRedirection();
await logoutRedirection();
},
});
};

View File

@ -45,7 +45,7 @@ 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"));
@ -53,7 +53,7 @@ export const useAxiosInstance = () => {
return Promise.reject(new Error("Network error"));
}
if (error.response.status === 401) {
logoutRedirection(true);
await logoutRedirection(true);
}
return Promise.reject(error.response.data);