0

so in one component I'm having a form and after filling the form details, when the send button is clicked I send the data in encrypted format to another component using header. Belowis the code:

send(){
     this.router.navigate(['/customerportal/insta-pay/insurance-plan'],{
        queryParams:{data:btoa(JSON.stringify(data))}
      })
}

and when I look at the header of the component, I find this:

http://localhost:4200/customerportal/insta-pay/insurance-plan?data=W3siY29udGFjdCI6eyJtb2JpbGVOdW1iZXIiOiI5OTg5ODM1ODk1IiwiZW1haWwiOiJ2aXNoYWwxMjNAZ21haWwuY29tIiwiZmlyc3ROYW1lIjoiZmRudnZu

And, what I want is that I want to trim the header URL after data=W3siY29udGFjdCI6eyJtb2JpbGVOdW1iZXIiOiI5OT

and also that this data should be deleted completely as it is showing/visible in the sources tab of the browser and when I click on it the data is visible and that page is still accessible with all the sensitive data information.

Anonymous
  • 95
  • 10
  • If you don't want to pass the `data` parameter anymore, just remove it from the `queryParams` object altogether. – Octavian Mărculescu Nov 13 '21 at 09:40
  • I do want to pass the data, but after using that I want to remove data from parameter, is there any way of doing that? – Anonymous Nov 13 '21 at 09:56
  • I think it should be possible if you navigate again to the same route, without specifying the query params. Have a look at [a similar stack overflow question](https://stackoverflow.com/questions/43665206/angular2-how-to-clear-url-query-params-on-router-navigate) for inspiration on how to do it. – Octavian Mărculescu Nov 13 '21 at 11:34

1 Answers1

0

If I understand well your problem, using query params doesn't seem to be the correct way to pass your data param.
Check This Link to have a complete answer on how we can pass params through Angular routing, and choose the most suited solution to your case ;)

seriously
  • 1,202
  • 5
  • 23
ppeinado
  • 61
  • 3