Page beforeEnter can't make it work

I got this on Routes, set a localStorage key to know if the user can enter the page (turnos.html), if not navigate to another page (turnodado.html).

routes: [
        ...
        {
            path: '/turnos/',
            url: 'turnos.html',
            name: 'turnos',
            beforeEnter: function (routeTo, routeFrom, resolve, reject) {
              if (localStorage.getItem('turno') === null) {
                  console.log('antes1');
                resolve({ url: 'turnodado.html' });
              } else {
                // don't allow to visit this page for unauthenticated users
                  console.log('volver');
                  resolve({ url: 'turnos.html' })     
              }
            },
            options: {
                transition: 'f7-parallax',
            },
    },
  ],

On the console I see the console.log(‘antes1’) that I added to check if it works, but always show me the page turnos.html. Enter to the page turnodado.html, but then shows turnos.html.

At the moment I don’t set anything to localStorage so the if statement is true, just to check if it’s works.

What i’m doing wrong.

Resolve change to reject(); this.navigate(…)

beforeEnter’s resolve() doesn’t accept any arguments. You missed it with route async that you nee to use, and remove url prop from route

thanks this works for me.

{
            path: '/turnodado/',
            url: 'turnodado.html',
            name: 'turnodado',
            options: {
                transition: 'f7-parallax',
            },
    },
        {
            path: '/turnos/',
            url: 'turnos.html',
            name: 'turnos',
            beforeEnter: function (routeTo, routeFrom, resolve, reject) {
              if (localStorage.getItem('turno') === null) {
                  console.log('antes1');
                  reject(); 
                  this.navigate('/turnodado/');
              } else {
                // don't allow to visit this page for unauthenticated users
                  console.log('volver');
                  
              }
            },
            options: {
                transition: 'f7-parallax',
            },
    },