Only fetch user endpoint when loggedIn state is not true, and update loginstate
continuous-integration/drone/push Build is passing Details

main
Filip Borum Poulsen 3 years ago
parent aecb1d3c80
commit 128fe1557c

@ -122,12 +122,17 @@ export default {
},
async created() {
// this.parseQueryFilters();
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/user`, {
credentials: import.meta.env.DEV ? "include" : undefined
});
if (res.status === 401 || res.status === 403) {
this.setLoginState(false);
this.$router.push({ path: "/login" })
if (!this.loggedIn) {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/user`, {
credentials: import.meta.env.DEV ? "include" : undefined
});
if (res.status === 401 || res.status === 403) {
this.setLoginState(false);
this.$router.push({ path: "/login" })
}
else if (res.status === 200) {
this.setLoginState(true);
}
}
},
data() {

Loading…
Cancel
Save