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?