1 // routing guard 2 router.beforeEach ((to, from, Next) => { . 3 // Get the user logs in successfully saved in the local token . 4 the let = localStorage.getItem token ( "token" ) . 5 // If token exists, i.e., the user has logged in . 6 IF (token) { . 7 IF (to.meta.requireAuth) { . 8 Next () . 9 } the else { 10 Next ({path: '/ Home' }) . 11 } 12 is } the else { 13 is IF (to.path === '/ Home' ) { 14 next({ path: '/login' }) 15 } else { 16 next() 17 } 18 } 19 })