docs: fix HttpClient logging's sample

This commit is contained in:
WilliamKoza 2017-07-16 12:00:40 +02:00 committed by Alex Rickabaugh
parent 87157d7089
commit ac92c3bb26

View File

@ -389,12 +389,12 @@ export class TimingInterceptor implements HttpInterceptor {
constructor(private auth: AuthService) {} constructor(private auth: AuthService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const elapsed = Date.now(); const started = Date.now();
return next return next
.handle(req) .handle(req)
.do(event => { .do(event => {
if (event instanceof HttpResponse) { if (event instanceof HttpResponse) {
const time = Date.now() - started; const elapsed = Date.now() - started;
console.log(`Request for ${req.urlWithParams} took ${elapsed} ms.`); console.log(`Request for ${req.urlWithParams} took ${elapsed} ms.`);
} }
}); });