Skip to content

Commit 6482e67

Browse files
committed
revert: axios plugin
1 parent 7a978d1 commit 6482e67

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

plugins/axios.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ const axios: Plugin = ({$axios, redirect, $auth, app}) => {
1616
return response
1717
},
1818
async (error) => {
19-
const status = parseInt(error.response && error.response.status);
20-
const shouldRefresh = [401, 403].includes(status);
21-
if (shouldRefresh) {
22-
await $auth.logout();
23-
}
24-
if (shouldRefresh && app.router && app.router.currentRoute.path !== '/login') {
19+
const status = error.response.status;
20+
21+
if ([401, 403].includes(status) && app.router && app.router.currentRoute.path !== '/login') {
22+
23+
if($auth.loggedIn) {
24+
await $auth.logout();
25+
}
26+
2527
redirect(status, "/login");
2628
} else {
2729
return Promise.reject(error);

0 commit comments

Comments
 (0)