Interceptor in angular 18

Discussão em 'Angular' iniciado por Bharti Singh, Outubro 21, 2024.

  1. Bharti Singh

    Bharti Singh Guest

    import { HttpInterceptorFn } from '@angular/common/http';

    export const customInterceptor: HttpInterceptorFn = (req, next) => {
    debugger;
    console.log('hellow');

    return next(req);
    };



    import { JsonPipe } from '@angular/common';
    import { HttpClient } from '@angular/common/http';
    import { Component, inject, OnInit } from '@angular/core';

    @Component({
    selector: 'app-dashboard',
    standalone: true,
    imports: [JsonPipe],
    templateUrl: './dashboard.component.html',
    styleUrl: './dashboard.component.css'
    })
    export class DashboardComponent implements OnInit{

    http = inject(HttpClient);
    userlist: any[]=[];
    ngOnInit(): void {
    this.getallwalks();
    }

    getallwalks(){
    debugger;
    this.http.get("http://localhost:5134/api/Walks").subscribe((res:any)=>{
    this.userlist = res;
    })
    }

    }


    This is custom interceptor and dashboard component. interceptor is not hitting and using angular 18.

    I entered the provide httpclient in app.config file also.

    Continue reading...

Compartilhe esta Página