Hi,

in the below code:

import { TokenApiModel } from '../model/token.api.model';
import { Router } from '@angular/router';
import { NgToastService } from 'ng-angular-popup';
import { AuthService } from '../services/authService';
import { Injectable } from '@angular/core';
import {
  HttpRequest,
  HttpHandler,
  HttpInterceptor,
  HttpErrorResponse,
  HttpEvent
} from '@angular/common/http';
import { catchError, Observable, switchMap, throwError } from 'rxjs';
import { token } from 'aws-sdk/clients/sns';

@Injectable()
export class TokenInterceptor implements HttpInterceptor {

  constructor(private auth: AuthService, private toast: NgToastService, 
private router: Router) {}

  intercept(request: HttpRequest<any>, next: HttpHandler): Observable<
HttpEvent<any>> {
    const myToken = this.auth.getToken()
    console.log("token is ok...")

    // this.start.load();
    if(myToken){
      request = request.clone({
        setHeaders: {Authorization: "Bearer "+ myToken}
      })
    }

    return next.handle(request).pipe(
      catchError((err)=>{
        if(err instanceof HttpErrorResponse){
          if(err.status === 401){
            //this.toast.warning({detail:"Warning", summary:"Token is 
expired, Please Login again"});
            //this.router.navigate(['login'])
            //handle
            return this.handleUnAuthorizedError(request,next);
          }
        }
        return throwError(()=> err)
      })
    );
  }

I have error the return statement:
return next.handle(request).pipe(

error:

Type 'Observable<unknown>' is not assignable to type 
'Observable<HttpEvent<any>>'.
Type 'unknown' is not assignable to type 'HttpEvent<any>'

how to solve this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/352676e5-845b-46f0-ab5b-13e150b6df14n%40googlegroups.com.

Reply via email to