Angular EXCEPTION: No Provider For Http! Error Fix

Fixing EXCEPTION: No Provider For Http! error

To avoid Angular EXCEPTION: No provider for Http! error we need to import HttpClientModule from @angular/common/http.

import { HttpClientModule } from '@angular/common/http';

@NgModule({
imports: [
BrowserModule,
HttpClientModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }

And this HttpClientModule introduced in Angular 4.3.

If you are using earlier versions of Angular import HttpModule from @angular/http to fix EXCEPTION: No provider for Http!

import { HttpModule } from '@angular/http';

@NgModule({
imports: [
BrowserModule,
HttpModule
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }

And this HttpModule is deprecated from Angular 5.2 version.

Avatar

Arunkumar Gudelli

Liked this post? Subscribe
Next
Previous