vue.jsionic-framework

useIonRouter how to replace whole URL


I am using Ion Router from Ionic, and I would like to replace the entire path.

My path:

http://localhost:3000/app/integrations

I would like to go to:

https://app.hubspot.com/oauth/

But I am left with this:

http://localhost:3000/app/https://app.hubspot.com/oauth/

How can I replace the whole URL so I get something similiar as when using this:

window.location.href = URL;

So that I get only the:

https://app.hubspot.com/oauth/

The code I use:

import { useIonRouter } from '@ionic/vue';

const ionRouter = useIonRouter();

ionRouter.replace(URL);

I tried replace and also the .push method both do not work for me please help.


Solution

  • You can try below code for redirect to other link

        // take variable and assign variable
        let url = "https://app.hubspot.com/oauth/"
        window.location.href = url
    
        // direct assign a value
        window.location.href = "https://app.hubspot.com/oauth/"
    

    if it's not working for you please let me know.