0

I have a ionic-refresher component, and in it i am trying to use window.location.href, and it works when i do not have any variables in the value, like this

window.location.href = '/tab1';

but it does not work when i do have variables, like this

window.location.href = '/listing/' + id

Any ideas on how to solve this?

What i have tried is window.open(), window.replace(), history.go(0), history.push().

Full code here

<IonRefresher slot='fixed' onIonRefresh={doRefresh} 
    pullFactor={0.5} pullMin={100} pullMax={200}>
    <IonRefresherContent></IonRefresherContent>
</IonRefresher>

function doRefresh(event: CustomEvent<RefresherEventDetail>) {
        
        // window.open("/listings/" + id.id, "_self")
        
        // history.push("/listings/" + id.id)
  
        // history.go(0)

      }

EDIT: It's able to catch the variables, but not email id specifically. I will make it work with user id instead of email id.

sid0972
  • 141
  • 1
  • 4
  • 13

2 Answers2

0

First Upon you will check that you define your path with id like <Route path="/listings/:id" component={listening}/> in App.js

then you will do

function doRefresh(event: CustomEvent<RefresherEventDetail>) {
      
     history.push(`/listings/${id.id}`)
        
  }
0

To anyone who is wondering, i encoded the url using base64 and then decoded it to handle email address. More information here

sid0972
  • 141
  • 1
  • 4
  • 13