I have a strange error. Usually (I did my googling), in this case of errors Angular specifies in square brackets which exactly module/service/provider/etc caused the problem
Here is what worked for me (Angular 7):
First import HttpClientModule in your app.module.ts if you didn't:
import { HttpClientModule } from '@angular/common/http';
...
imports: [
HttpClientModule
],
Then change your service
@Injectable()
export class FooService {
to
@Injectable({
providedIn: 'root'
})
export class FooService {
Hope it helps.
Edit:
providedIn
Determines which injectors will provide the injectable, by either associating it with an @NgModule or other InjectorType, or by specifying that this injectable should be provided in one of the following injectors:
'root' : The application-level injector in most apps.
'platform' : A special singleton platform injector shared by all applications on the page.
'any' : Provides a unique instance in every module (including lazy modules) that injects the token.
Be careful platform
is available only since Angular 9 (https://blog.angular.io/version-9-of-angular-now-available-project-ivy-has-arrived-23c97b63cfa3)
Read more about Injectable here: https://angular.io/api/core/Injectable
It also might be that you haven't declared you Dependency Injected service, as a provider in the component that you injected it to. That was my case :)