your recipe card header background

    Angular HttpInterceptor Empty

    0

    0

    lucycodes42

    Angular snippets for TypeScript

    The @Injectable() decorator registers the YourInterceptor class as a HTTP interceptor. The intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> function takes a req object and returns an Observable that emits HttpEvent objects. The handle(req: HttpRequest<any>) function of the next object receives a req object and calls the handle() method of the HttpHandler object that was passed as an argument.

    Library: angular

    Shortcut: a_http_interceptor

    import { Injectable } from '@angular/core';
    import { HttpInterceptor, HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http';
    import { Observable } from 'rxjs';
    
    @Injectable()
    export class YourInterceptor implements HttpInterceptor {
      intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        return next.handle(req);
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.