NuxtN
Nuxt11mo ago
thergbcrow

Getting Cookie From Middleware

export default defineNuxtRouteMiddleware(async (to, from) => {
const isAuthenticated = useCookie('token')

if((to.name === "login" || to.name === "register") && isAuthenticated.value) {
console.log('user is logged in')
} else {
console.log(isAuthenticated)
}
})

why this does not work?
Was this page helpful?