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

Angular HttpInterceptor does not work in first call

$
0
0

@bhandaribhumin3i wrote:

First time application was working good after kill application I didn’t see HTTP interceptor console log in Xcode log even canActivate console log is not displayed. i was use ngxs for store.

router

const routes: Routes = [
  {
    path: '',
    redirectTo: 'insider',
    pathMatch: 'full',
    canActivate: [AuthGuard] // no effect if remove
  },
  { path: 'insider', loadChildren: './pages/insider/insider.module#InsiderPageModule', canActivate: [AuthGuard] },
  { path: 'login', component: LoginPage }
];
canActivate(): Observable<boolean> | Promise<boolean> | boolean {
    let serverToken = this
      .store
      .selectSnapshot(AuthState.getAuthenticationResult);
    console.log('canActivate serverToken', JSON.stringify(serverToken)); // first time not displayed
    if (!serverToken) {
          this.router.navigate(['/login']);
    } else {
      return new Promise((resolve) => {
        this._ADAL.checkTokenRefresh().then((response) => {
          console.log('response refreshtoken', response);
        }, (error) => {
          console.log('response refreshtoken error', error);
        });
        resolve(true);
      })
    }

  }

interceptor code

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    console.log('im in intercept '); //not display first time
    return next.handle(this.addAuthenticationToken(request));
  }

XCODE LOG

**2019-10-23 12:36:23.445347+0530 @[733:122720] Apache Cordova native platform version 5.0.1 is starting.**

**2019-10-23 12:36:23.446483+0530 @[733:122720] Multi-tasking -> Device: YES, App: YES**

**2019-10-23 12:36:23.469083+0530 @[733:122720] CDVWKWebViewEngine: trying to inject XHR polyfill**

**2019-10-23 12:36:23.632761+0530 @[733:122720] CDVWKWebViewEngine will reload WKWebView if required on resume**

**2019-10-23 12:36:23.632815+0530 @[733:122720] Using Ionic WKWebView**

**2019-10-23 12:36:23.633319+0530 @[733:122720] [CDVTimer][console] 0.061035ms**

**2019-10-23 12:36:23.633407+0530 @[733:122720] [CDVTimer][handleopenurl] 0.054955ms**

**2019-10-23 12:36:23.634833+0530 @[733:122720] Unlimited access to network resources**

**2019-10-23 12:36:23.634894+0530 @[733:122720] [CDVTimer][intentandnavigationfilter] 1.464963ms**

**2019-10-23 12:36:23.634971+0530 @[733:122720] [CDVTimer][gesturehandler] 0.056982ms**

**2019-10-23 12:36:23.635025+0530 @[733:122720] [CDVTimer][backgroundfetch] 0.035048ms**

**2019-10-23 12:36:23.635172+0530 @[733:122720] CDVIonicKeyboard: resize mode 1**

**2019-10-23 12:36:23.635912+0530 @[733:122720] [CDVTimer][cdvionickeyboard] 0.840902ms**

**2019-10-23 12:36:23.638597+0530 @[733:122720] [CDVTimer][splashscreen] 2.646923ms**

**2019-10-23 12:36:23.640769+0530 @[733:122720] [CDVTimer][statusbar] 2.047896ms**

**2019-10-23 12:36:23.643838+0530 @[733:122720] [CDVTimer][file] 3.000975ms**

**2019-10-23 12:36:23.643960+0530 @[733:122720] Sentry Cordova Plugin initialized**

**2019-10-23 12:36:23.643987+0530 @[733:122720] [CDVTimer][sentry] 0.101924ms**

**2019-10-23 12:36:23.644009+0530 @[733:122720] [CDVTimer][TotalPluginStartup] 10.814905ms**

**2019-10-23 12:36:23.649681+0530 @[733:122720] createNotificationChecker**

**2019-10-23 12:36:23.649718+0530 @[733:122720] not coldstart**

**2019-10-23 12:36:23.719329+0530 [733:122720] active**

**2019-10-23 12:36:23.719920+0530 [733:122720] PushPlugin skip clear badge**

**2019-10-23 12:36:26.776827+0530 [733:122720] Ionic Native: deviceready event fired after 1576 ms**

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70759

Trending Articles



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