Angular EXCEPTION: No Provider For Http! Error Fix

Fixing EXCEPTION: No Provider For Http! error

EXCEPTION: No Provider For Http! Error Fix

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.

Spread the word :
Subscribe & Get free link to download 900+ material icons

Avatar
Arunkumar Gudelli

I am One among a million Software engineers of India. I write beautiful markup.I make the Web useful.

Next
Previous