Home > Software design >  I am not able to redirect registered user to dashboard page with link
I am not able to redirect registered user to dashboard page with link

Time:12-16

if (response.success) {
            this.redirectURL = response.data.loginUrl;
            // this.URL='http://' location.host '/login' '/' this.redirectURL;
            this.router.navigate(['/login?token=', this.redirectURL]);}

Here is the code ,it should move me to cognito page but its moving to login page in angular I am not sure where I am wrong

CodePudding user response:

use (plus) instead of ,(comma)

 this.router.navigate(['/login?token=' this.redirectURL]);}

CodePudding user response:

If you want to use query params, you can also adopt this approach.

this.router.navigate(['login'], { queryParams: { token: 20 } });

Most likely the reason behind the issue you are facing is that the comma-separated navigation turns to slash-separated one, e.g.

let redirectURL = '1234'
this.router.navigate(['/login?token=', redirectURL]) 
// this line above results to  /login?token=/1234'

So in order to avoid that you should either use the solution that I suggest or the one mentioned by abhishek sahu, where the usage of for concatenation is encouraged.

  • Related