Skip to content

Commit

Permalink
show spinner on call every api
Browse files Browse the repository at this point in the history
  • Loading branch information
pragati-atharva committed Sep 23, 2022
1 parent 678b234 commit f8bca5f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/core/auth/interceptor/token.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import {
HttpEvent,
} from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
import { catchError, finalize, map, switchMap } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { CustomToastrService } from '../../shared/services/toastr/custom-toastr.service';
import { CommonService } from '../../shared/services/common/common.service';
import { ConstantClass } from 'src/app/shared/constants/constants';
import { APIs } from 'src/app/shared/constants/apis';
import { Router } from '@angular/router';
import { AuthService } from '../service/auth/auth.service';
import { LoginResponse } from '../models/user';
import { NgxSpinnerService } from 'ngx-spinner';

@Injectable()
export class TokenInterceptor implements HttpInterceptor {
constructor(
public authService: AuthService,
private commonService: CommonService,
private customToastrService: CustomToastrService,
private router: Router
private spinner: NgxSpinnerService
) {}

intercept(
Expand All @@ -42,7 +42,9 @@ export class TokenInterceptor implements HttpInterceptor {
});
}

this.spinner.show();
return next.handle(request).pipe(
finalize(() => this.spinner.hide()),
map((res: any) => {
return res;
}),
Expand Down

0 comments on commit f8bca5f

Please sign in to comment.