question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HttpClientModule imported in AvatarModule override HttpClient defined in the AppModule

See original GitHub issue

Hi @HaithemMosbahi

First, thank u for this library, good job. It’s saving me a lot of time.

I’m facing an issue, I will try to explain it. In my app (Ionic3/Angular5), I have injected the HttpClientModule in the root module, aka AppModule, with a few HTTP interceptors.

Then I have a feature module (lazy loaded) where I’m using ngx-avatar. It is working but the services I have in that module stop working after adding the AvatarModule. They are not using the HTTP interceptors anymore.

I’ve forked your repo and seems it’s because the AvatarModule is importing also the HttpClientModule so there are 2 instances in the angular dependency injection system and the feature module is using the one provided by the AvatarModule.

I have a patch removing the import for the HttpClientModule in the AvatarModule and everything works again. I can send a PR if you agree.

thx

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
datenciacommented, May 8, 2019

@nickraphael @datencia @odahcam Sorry for the late reply. You are right, httpModule must be loaded only once in the application and therefore the library should not import it. I will make a fix and release a new version today

thx, I have a patch in my fork, I can send a PR if u agree.

0reactions
HaithemMosbahicommented, May 8, 2019

I just published new version v3.4.0 that includes the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HttpClientModule Import in sub-modules override HttpClient ...
Hi guys, i found a little problem with the HttpClientModule, If a define a HTTP_INTERCEPTOR in app module if in a submodule (lazy...
Read more >
Getting Error with HttpClient Module in angular - Stack Overflow
imports of AppModule, but could not be resolved to an NgModule class. This likely means that the library ( @angular/common/http ) which declares ......
Read more >
Angular - How to use HttpClientModule? - Ninja Squad
import { HttpClientModule } from '@angular/common/http';. The second step is to replace every instance of the service Http with the new service ...
Read more >
HttpClientModule - Angular
Configures the dependency injector for HttpClient with supporting services for XSRF. Automatically imported by HttpClientModule .
Read more >
Exploring the HttpClientModule in Angular - InDepth.Dev
Why is it recommended to load the HttpClientModule only once in AppModule ... export class HttpClient { constructor (private handler: HttpHandler) { }...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found