Skip to content

Commit e7993ea

Browse files
committed
refactor(sara.js): optimize token revocation
1 parent 2400d7a commit e7993ea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/plugins/axios.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ axiosClient.interceptors.response.use(
5151
// Do something with response data
5252
(response) => response,
5353
// Do something with response error
54-
(error) => Promise.reject(error),
54+
(error) => {
55+
if (error.response.status === 401) {
56+
localStorage.removeItem(saraTokenName);
57+
setTimeout(() => {
58+
location.reload();
59+
}, 3000);
60+
}
61+
return Promise.reject(error);
62+
},
5563
);
5664

5765
const extension = {

0 commit comments

Comments
 (0)