Skip to content

Instantly share code, notes, and snippets.

@fasfsfgs
Last active August 18, 2021 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasfsfgs/850575a7bfb1ffac40f241301d708c77 to your computer and use it in GitHub Desktop.
Save fasfsfgs/850575a7bfb1ffac40f241301d708c77 to your computer and use it in GitHub Desktop.
angular interceptor
export const BYPASS_LOG = new HttpContextToken(() => false);
export class MyLogInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (req.context.get(BYPASS_LOG) === true)
return next.handle(req);
console.log(`req to ${req.url}`);
return next.handle(req);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment