使用来自响应的后端信息:Angular

Using backend information from response: Angular

我的后端给我一个文本数组:

['lamIt','lamItLite']

这是我获取版本 lamIt 或 lamItLite 的 GET 请求:

getVersion() {
    const url = this.lamItUrl + this.versionExt + 'lamit/version';
    console.log(this.environment.getConfig('Url'));
    const params = new HttpParams()
        .set('lanId', this.authService.username)
        .set('domain', 'NAM');
    const options = {
        params: params,
        responseType: 'text'as 'text' // Getting back text not JSON.
    };
    return this.http.get(url, options);
}

这就是我重新路由用户以便在提交表单后进入 lamIt 或 lamItLite 的方式:

onFormSubmit(f: NgForm) {
    if (this.signInForm.valid) {
      this.authService.username = this.signInForm.value.username;
      this.authService.password = this.signInForm.value.password;
      this.authService.loginUser().subscribe(
        response => {
          this.authService.isAuthenticated = true;
          this.authService.storeToken(response['access_token'], response['refresh_token']);
          this.daq.getVersion().subscribe(
            version =>  {
              this.authService.data = version;
              console.log(version);
              if (version === 'lamIt') { // checks if user has lam, it access, backend returned text not string, see daq service.
                this.router.navigate(['/lamit']);
              } else if (version === 'lamItLite') {
                this.router.navigate(['/lamitlite']);  // checks if user has lam it lite access, backend returned text not string, see lam service.
              } else if (version === 'lamIt' || 'lamItLite') {
                this.router.navigate(['/lamit']);  // checks if user has lam it and lamit lite, backend returned text not string, see lam service.
              }
              this.onLoginError(this.groupLoginErrorMessage);

            }
          );
        }, (error) => {
          console.log(error);
          this.onLoginError(this.invalidCredentialsMessage); // wrong password for auth
        }
      );
    }
  }

如何在前端使用后端提供的内容(前面提到的文本数组)将用户重定向到正确的应用程序?

问题是,我不知道如何使用后端给我的东西,以便我可以将用户重定向到应用程序的正确版本。

需要遍历数组,因为后端 return 一个数组

 this.daq.getVersion().subscribe(
     version =>  {
          this.authService.data = version;
          console.log(version);
          version.foreach((item) => {
               this.router.navigate(['/' + lamit]);
          }) 
          this.onLoginError(this.groupLoginErrorMessage);

     }
 );