import { Injectable } from '@angular/core' ; import { HttpRequest , HttpHandler , HttpEvent , HttpInterceptor } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { Store } from '../services/store.service' ; @ Injectable ( ) export class TokenInterceptor implements HttpInterceptor { constructor ( private store ) { } intercept ( request , next ) { const token = this . store . token ; request = request . clone ( { setHeaders : { Authorization : `Bearer ${ token }` } } ) ; return next . handle ( request ) ; } }