Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

74
Vistas
Vue 3 hook in catch

I have some, not to say problems but concerns how to redirect user to some page if there is an error. So I have request that is called ExecuteLoginRequest, and inside I have catch function that is redirecting user if he cancel his login. And it looks like this:

await ExecuteLoginRequest(props.pre_auth_code)
      .catch(reason => {
        error.value = reason;

        if(router.currentRoute.value.query.error === 'canceled_by_user'){
          router.push({name: 'home.index'})
        }

        throw new Error(reason)
      }).then(async (value) => {
        return value;
      })
      .then(value => {
        resumeUser();
        return value;
      })

So the concern is if(router.currentRoute.... Because when client click on login button, he will be redirected to staging website, and from staging it will redirect to my localhost and pass the token. So when he cancel his login, he will be redirected to error page, and it has query canceled_by_user and in this case, I need to redirect him to home page of my localhost. But in this case it will redirect him back to login page. What I need here is a hook that will wait for my page and redirect him back where I want. How could I implement hook in this if statement?

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.