Angular2/http Exception no ConnectionBackend

后端 未结 3 716
情书的邮戳
情书的邮戳 2020-12-20 13:14

I attempting to use an angular2 http request, but I am getting the following error: [Error] EXCEPTION: No provider for ConnectionBackend! (AppComponent -> Http -> Connection

3条回答
  •  执念已碎
    2020-12-20 13:29

    Remove HTTP_BINDINGS from your code. They are deprecated and reference HTTP_PROVIDERS, so it's like you're using providers twice.

    bootstrap(AppComponent, [HTTP_PROVIDERS]);
    

    Also you don't need providers: [Http] in your component, since you injected HTTP_PROVIDERS in bootstrap. Adding it to the component's providers will create new instance of the service.

    @Component({
      providers: []
    })
    

提交回复
热议问题