Error: No provider for HttpHandler in angular2

后端 未结 2 575
别跟我提以往
别跟我提以往 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 17:41

    Add HttpClientModule to your imports[] in app.module.ts. This might be one of the mistakes.

    0 讨论(0)
  • 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
     ],
     ...
    
    0 讨论(0)
提交回复
热议问题