import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs/Observable' ; import { HttpRequest , HttpHandler , HttpEvent , HttpInterceptor } from '@angular/common/http' ; @ Injectable ( ) export class TokenInterceptor implements HttpInterceptor { intercept ( request , next ) { request = request . clone ( { setHeaders : { Authorization : `JWT ${ localStorage . getItem ( 'token' ) }` } } ) ; return next . handle ( request ) ; } }