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