import { HttpEvent , HttpHandler , HttpInterceptor , HttpRequest } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs' ; import { tap } from 'rxjs/operators' ; import { TokenService } from './token.service' ; @ Injectable ( ) export abstract class SpotifyAuthInterceptor implements HttpInterceptor { constructor ( private tokenSvc ) { } abstract doOnError ( err ) ; public intercept ( req , next ) { const authReq = req . clone ( { setHeaders : this . tokenSvc . authHeader } ) ; return next . handle ( authReq ) . pipe ( tap ( ( ) => { } , this . doOnError ) ) ; } }