restructure api request

This commit is contained in:
2023-05-02 21:31:30 +10:00
parent e8e1e91d1c
commit ded5caf271

View File

@@ -393,7 +393,9 @@ router.beforeEach(async (to, from, next) => {
if (to.meta.middleware == "authenticated") {
if (userStore.id) {
try {
let res = await api.get("/me");
let res = await api.get({
url: "/me",
});
userStore.setUserDetails(res.json.user);
} catch (err) {
if (err.status == 401) {
@@ -407,12 +409,22 @@ router.beforeEach(async (to, from, next) => {
name: "login",
query: { redirect: encodeURIComponent(to.fullPath) },
});
} else {
next();
return;
}
} else {
next();
}
api.post({
url: "/analytics",
body: {
type: "pageview",
attribute: to.fullPath,
},
}).catch(() => {
/* empty */
});
next();
});
router.afterEach((to, from) => {