Nested http requests in map

Hello,

I wrote something like an interceptor which recognizes a session expired and make a relogin to make the http call.
So when I call readPersons I want to detect the session expired and make a relogin and then call the readPersons again. So the readPersons function in PersonPage should get the answer after the second backend call readPersons.
But this not works.

Here is my PersonPage…

readPersons(){
this.backendService.readPersons().subscribe(
        success => this.handleSuccess(success),
        error => {
          console.log(error);
        }
      );
}

Here is the backendService…
My backend returns 303 when session expired.

readPersons(){
    return this.http.get(PERSONS_URL)
      .map(this.handleSuccess)
      .catch(this.handleError);


  private handleSuccess() {
    if (res.status === 303) {
      return _this.loginService.login().map(() =>{
            return _this.http.get(PERSONS_URL);
          }
    }

    return res.json() || {};
  }

Not exactly an answer, but I was surprised to see your code. if you didn’t know, Angular has interceptors.
https://angular.io/api/common/http/HttpInterceptor

Yeah it is not an interceptor. It is either nested http requests with map.