How to Bypass HTTP Interceptor while calling api

When injected, HttpBackend dispatches requests directly to the backend, without going through the interceptor chain.

import {HttpBackend, HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class BypassHttpService {
  private httpClient: HttpClient;
  constructor(
    private handler: HttpBackend,
  ) {
    this.httpClient = new HttpClient(handler);
  }


  getData() {
    return this.httpClient.get(url);
  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *