0

I've followed the tutorial to make an Http request, but there is still the error "Cannot find name HttpClient".
In my app.module.ts file I have imported:

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

imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp)
]

Then, in the page where I want to perform the request I did:

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

 constructor(public navCtrl: NavController, 
             public navParams: NavParams, public http: HttpClient)

The error is in HttpClient parameter in the constructor.

Don't know if it's helpful, but these are the current versions in my project:

"dependencies": {
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@angular/platform-server": "4.1.3",
"@ionic-native/core": "3.10.2",
"@ionic-native/splash-screen": "3.10.2",
"@ionic-native/status-bar": "3.10.2",
"@ionic/storage": "2.0.1",
"@types/leaflet": "^1.0.59",
"ionic-angular": "3.4.2",
"ionicons": "3.0.0",
"leaflet": "^1.0.3",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.7",
"@ionic/cli-plugin-ionic-angular": "1.3.1",
"ionic": "3.7.0",
"typescript": "2.3.3"
},
Drakkin
  • 878
  • 12
  • 27
Usr
  • 2,628
  • 10
  • 51
  • 91
  • 1
    Make sure you have installed `angular@^4.3.0` dup of https://stackoverflow.com/questions/45455162/angular-2-error-httpcliendmodule – yurzui Aug 11 '17 at 15:30
  • Hi, the import is correct from '@angular/common/http' , but how do I install angular to the latest version? – Usr Aug 11 '17 at 15:38
  • 1
    Replace all `"4.1.3"` with `4.3.3` remove `node_module/@angular` folder and run `npm i` – yurzui Aug 11 '17 at 15:41

0 Answers0