Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Interceptors not running #162

@will093

Description

@will093

I have imported HttpModule and HttpInterceptorModule, and created an interceptor service:

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { HttpInterceptorService } from 'ng-http-interceptor';

@Injectable()
export class HttpErrorResponseInterceptor {

  constructor(private http: Http, private httpInterceptor: HttpInterceptorService) { }

  initialise() {

    this.httpInterceptor.request().addInterceptor((data, method) => {
      console.log(method, data);
      return data;
    });

    this.httpInterceptor.response().addInterceptor((res, method) => {
      return res.do(r => console.log(method, r));
    });

    this.http.get('/')
      .subscribe(console.log);
  }
}

initialise() is then called in the top level AppComponent.

When I debug in Chrome/IE/Firefox I can see http.get is called - but the interceptors never run, and there are no errors. I have tried injecting InterceptableHttp instead of Http, and the interceptors still don't run.

I am using Angular 4, specifically, the versions I am using are:

"@angular/http": "^4.3.1",
"ng-http-interceptor": "^3.1.2",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions