Dynamic render function in Vue instance based on Authentication
Hi,
I'm adding JWT authentication to my Vue app and I have my Login.vue and App.vue seperated which means that I don't want to render the App.vue when the user is not logged in.
new Vue({
router,
render: function (app) {
if (this.$auth.check()) {
return app(App);
} else {
return app(Login);
}
}
}).$mount('#app')
This works but since
this.$auth.check()
Takes a second to load you see the Login app being rendered for a second and then it switches to the App. How can I fix this? I think I should use await but I can't get it to work properly.