I'm facing a problem with my navigation guard where the IDE is showing an error stating that requiresAuth is an unresolved variable.
router.beforeEach(async (to, from, next)=>{
if(to.matched.some((record)=> record.meta.requiresAuth)){
const currentUser = await getCurrentUser();
if(await currentUser){
next()
}
else{
next("/about")
}
}
});
This issue arises in my router setup, particularly in the second route which has the meta object containing the requiresAuth property that is unresolved.
const router = createRouter({
history:createWebHistory(),
routes:[
{
path:"/",
name:"Home",
component:Home,
},
{
path:"/dashboard",
component: Dashboard,
meta:{
requiresAuth:true,
}
}
]
})
Upon starting up the app, I encounter the following console error:
Error: Invalid navigation guard at vue-router.mjs:2008:47
The code fails to proceed beyond the first if statement in the beforeEach hook due to the unresolved requiresAuth variable.