Error: No provider for HttpHandler in angular2

后端 未结 2 568
别跟我提以往
别跟我提以往 2021-02-03 17:11

I am trying to implement HttpCache through interceptor. Following is the caching-interceptor.service.ts

import { HttpRequest, HttpResponse, HttpInterceptor, Http         


        
2条回答
  •  失恋的感觉
    2021-02-03 18:03

    HttpClient is introduced in angular 4.3,so if you want to use HttpClient you need to import HttpClientModule from '@angular/common/http'. Make sure to import HttpClientModule after BrowserModule as shown below. This official doc and so answer will give you indepth information.

    import { HttpClientModule } from '@angular/common/http';
    
    @NgModule({
     imports: [
       BrowserModule,
       HttpClientModule
     ],
     ...
    

提交回复
热议问题