mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 05:09:18 +00:00
improvement: better error checking on session handler
This commit is contained in:
@@ -46,7 +46,7 @@ const useAuth = () => {
|
|||||||
},
|
},
|
||||||
async error => {
|
async error => {
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
if (error.response.status === 403 && !originalRequest._retry) {
|
if (error?.response?.status === 403 && !originalRequest._retry) {
|
||||||
originalRequest._retry = true;
|
originalRequest._retry = true;
|
||||||
|
|
||||||
const { data } = await api.post("/auth/refresh_token");
|
const { data } = await api.post("/auth/refresh_token");
|
||||||
@@ -56,7 +56,7 @@ const useAuth = () => {
|
|||||||
}
|
}
|
||||||
return api(originalRequest);
|
return api(originalRequest);
|
||||||
}
|
}
|
||||||
if (error.response.status === 401) {
|
if (error?.response?.status === 401) {
|
||||||
localStorage.removeItem("token");
|
localStorage.removeItem("token");
|
||||||
localStorage.removeItem("username");
|
localStorage.removeItem("username");
|
||||||
localStorage.removeItem("profile");
|
localStorage.removeItem("profile");
|
||||||
|
|||||||
Reference in New Issue
Block a user