Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Http interceptor

$
0
0

@mdline wrote:

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().subscribe(() =>
          success => {
            return _this.http.get(PERSONS_URL);
          },
        error => {
          return error;
        }
      );
    }

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

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>