mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-10 04:06:18 +00:00
[update] handle response status code via axios
This commit is contained in:
parent
81878cda61
commit
fb1f99e98d
2 changed files with 19 additions and 5 deletions
|
@ -14,3 +14,17 @@ axios.interceptors.request.use(
|
||||||
},
|
},
|
||||||
(error) => Promise.reject(error),
|
(error) => Promise.reject(error),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
(error) => {
|
||||||
|
if (error.response) {
|
||||||
|
const statusCode = error.response.status;
|
||||||
|
// Check the status code
|
||||||
|
if (statusCode === 401) { // Unauthorized
|
||||||
|
return window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in a new issue