Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

466
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!