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.

Do not import `HttpClientModule`

See original GitHub issue

This might sounds a bit weird.

And I hope someone tells me I’m wrong.

I do have some interceptors in my app. I do use ngx-markdown within a lazy loaded module, let’s call it LazyModule. From LazyModule, every http request is not caught by any of my interceptors.

I’ve been digging on why this lazy loaded module especially, because I have others and it works fine with them.

Then I’ve found that issue: https://github.com/angular/angular/issues/20575

HTTP_INTERCEPTORS are reset when a lazy loaded module imports another module importing HttpClientModule and yes it’s an intended behavior. So it’s not going to change and we have to deal with it.

I have no idea how to manage that, but could you somehow remove the imports: [HttpClientModule] on this line?

Otherwise it means that people cannot use ngx-markdown into a lazy loaded module if they rely on some interceptors.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jfcerecommented, May 23, 2018

Look good at first sight … I’m gonna look at it tonight from home. Oh and by the way thanks a lot for doing the tests, usually people don’t care so much about it 😄

1reaction
maxime1992commented, May 23, 2018

@jfcere I’ve added a commit. Let me know what you think 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find the '@angular/common/http' module
Original answer: You need to inject HttpClient in your component/service not the module. If you import HttpClientModule in your @NgModule
Read more >
Angular - How to use HttpClientModule? - Ninja Squad
The first step is to remove the @angular/http package from your package.json file. Indeed the new HttpClientModule is in the @angular/common/ ...
Read more >
Communicating with backend services using HTTP - Angular
Before you can use HttpClient , you need to import the Angular HttpClientModule . Most apps do so in the root AppModule ....
Read more >
don't re-import HttpClientModule - Angular Checklist
One such functionality is the ability to specify interceptors that inspect and transform HTTP requests from your application to the server. When re-importing...
Read more >
HttpClient in angular not call HttpInterceptor #3532
Please define services with @Injectable({providedIn: 'root'}) decorator. And use this service in lazy-loaded components. Do not import HttpClientModule or do ...
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