title: not able to redirect using handlerror
body: <p>I'm trying to redirect to error component when response data have &quot;401&quot; error and below is my code
  but its not handling the error . I tried to redirect to external url but no luck.
  Please guide , Thanks in Adavance</p>
  <p><strong>Service.ts:-</strong></p>
  <pre><code>public searchGroups(searchReviewData: SurveillanceReviewSearchViewModel): Observable&lt;SurveillanceReviewSearchViewModel&gt; {
      this._urlSurveillanceDetails = this.baseHref + &quot;/ReviewProfile/SearchGroups&quot;;
      const headers: HttpHeaders = new HttpHeaders();
      headers.append('Content-Type', 'application/json');
      let getData = this.http.post&lt;SurveillanceReviewSearchViewModel&gt;(this._urlSurveillanceDetails, searchReviewData, { headers: headers })
        .pipe(
          catchError(this.handleError)
        );
      return getData;
    }
  
  
    handleError(data: any) {
      if (data instanceof ErrorEvent) {
  
      }
      else {
        switch (data.errorResponse.httpStatusCode) {
         case 401:
         this.router.navigate(['error', 'unauthorized']);
           break;       
  
        }
      } 
      // return an observable with a user-facing error message
      return throwError(
        'Something bad happened; please try again later:' + JSON.stringify(data.errorResponse.httpStatusCode));
  
    }
  </code></pre>
  <p><strong>Component.ts</strong></p>
  <pre><code>searchGroups(searchReviewData: SurveillanceReviewSearchViewModel) {
      this._surveillanceService.searchGroups(searchReviewData).subscribe(data =&gt; {
        if (data != undefined) {
          this.reviewData = data;
          if (data.reviews != null) {
            if (data.reviews.length == 1) {                
              this.pagerSelectedData = data.reviews;
              this.loading = false;                
  
            }
          }
          else {
            this.loading = true;
          }
        }
      });
    }
  </code></pre>
  <p><strong>ResponseJson from MVC controller:</strong></p>
  <pre><code>{
      &quot;loggedInUser&quot;: {
          &quot;v2020UserId&quot;: &quot;kdevisenakanthan&quot;
      },
      &quot;errorResponse&quot;: {
          &quot;errorCode&quot;: null,
          &quot;transactionId&quot;: null,
          &quot;httpStatusCode&quot;: 401
      }
  }
  </code></pre>