Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

468
Visualizações
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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda