-3

I am getting that error on trying to launch my app.

ERROR 
Error: StaticInjectorError(AppModule)[ApiUserService -> HttpClient]: 
  StaticInjectorError(Platform: core)[ApiUserService -> HttpClient]: 
    NullInjectorError: No provider for HttpClient!
Stack trace:
_NullInjector.prototype.get@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1218:19
resolveToken@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1516:17
tryResolveToken@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1458:16
StaticInjector.prototype.get@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1326:20
resolveToken@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1516:17
tryResolveToken@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1458:16
StaticInjector.prototype.get@webpack-internal:///./node_modules/@angular/core/esm5/core.js:1326:20
resolveNgModuleDep@webpack-internal:///./node_modules/@angular/core/esm5/core.js:11070:12
NgModuleRef_.prototype.get@webpack-internal:///./node_modules/@angular/core/esm5/core.js:12303:16
resolveDep@webpack-internal:///./node_modules/@angular/core/esm5/core.js:12793:12
createClass@webpack-internal:///./node_modules/@angular/core/esm5/core.js:12655:29
_createProviderInstance@webpack-internal:///./node_modules/@angular/core/esm5/core.js:12632:20
createProviderInstance@webpack-internal:///./node_modules/@angular/core/esm5/core.js:12473:12
createViewNodes@webpack-internal:///./node_modules/@angular/core/esm5/core.js:13945:53
createRootView@webpack-internal:///./node_modules/@angular/core/esm5/core.js:13847:5

I don't know how to fix that, the error seems to be in my ApiUserService,

https://gist.github.com/LarsE343/4fe09a513e4d0d77564a4b0eac30b8e2 //link to the ApiUserService Gist [Complete File]

Cœur
  • 37,241
  • 25
  • 195
  • 267
Lars Erhardt
  • 529
  • 1
  • 5
  • 8
  • Hi! Welcome to Stack Overflow. Please see [ask] and how to create a [mcve]: please post _all_ of the relevant code (including your main module, probably called `app.module.ts`) and details in the question itself. I've code-formatted the error for you, for readability, and cut the last part of the error since the relevant part, like most stack traces, is right at the top. Thanks! – msanford Mar 20 '18 at 14:47
  • Also, about _"when I launch my app"_ there are many ways to start an angular application. What exactly did you launch: `ng serve` or something else? – msanford Mar 20 '18 at 14:52
  • 1
    When you get an error message you should search/google that error message. That is what they are there for, to guide you to the root of whatever problem is occurring. In this case the error is `NullInjectorError: No provider for HttpClient`. If you had googled that you would have seen the above proposed duplicate, it was the 1st returned result. – Igor Mar 20 '18 at 14:54
  • If you are still stuck you will have to post your code by creating an [mcve]. See also [ask]. – Igor Mar 20 '18 at 14:55
  • My advice is more general about how to ask a good question, but @Igor's advice is crucially important, and comes before even asking here. – msanford Mar 20 '18 at 14:55
  • Hey, ty for your nice answer, it works now :) ty – Lars Erhardt Mar 20 '18 at 15:13
  • If my answer worked for you please mark it as the accepted answer, cheers! :) – Kyle Krzeski Mar 21 '18 at 00:31

1 Answers1

1

Shot in the dark here, but try to add HttpClientModule:

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

imports: [
  HttpClientModule
]

I'm guessing you forgot to add that to your app.module.ts.

Kyle Krzeski
  • 6,183
  • 6
  • 41
  • 52