Skip to content

Instantly share code, notes, and snippets.

@danielcrisp
Last active July 25, 2017 13:28
Show Gist options
  • Save danielcrisp/fd94fbff610c1db116051ce866e3671e to your computer and use it in GitHub Desktop.
Save danielcrisp/fd94fbff610c1db116051ce866e3671e to your computer and use it in GitHub Desktop.
TokenInterceptor - Async HTTP Interceptors with Angular 4
import { Injectable } from '@angular/core';
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { AuthService } from './auth.service';
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
constructor (private auth: AuthService) {}
intercept (request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log('Hello request!', request);
return next.handle(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment