[WIP] Фикс просроченного токена

This commit is contained in:
megavrilinvv
2022-12-07 14:51:12 +03:00
parent a4240f3651
commit a42d8aa30a
5 changed files with 23 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
import router from "@/router";
function prepareUrl(url) {
if (url.startsWith("http")) return url;
return `http://45.84.227.122:8080/api/${url}`;
@@ -12,7 +14,10 @@ function handleRequest(method, url, headers, attempts, body, type) {
})();
})
.then((res) => {
if (res) return res.json();
if (res.status === 401) {
localStorage.removeItem("tokenAccess");
return router.push("/login");
} else if (res) return res.json();
})
.catch((err) => {
return err;