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.

Error Circular dependency when adding either HttpClient or HttpService to AuthenticationService

See original GitHub issue

I’m submitting a…

[x] Bug report [ ] Feature request [ ] Documentation issue or request

Current behavior

Error Circular dependency when adding either HttpClient or HttpService to AuthenticationService

src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts src\app\core\interceptors\error-handler.interceptor.ts -> src\app\core\index.ts -> src\app\core\core.module.ts -> src\app\core\http\http.service.ts -> src\app\core\interceptors\error-handler.interceptor.ts

Expected behavior

Success compile and can call from HttpClient or HttpService

Minimal reproduction of the problem with instructions

  • Generate new project ngx new
  • Add HttpClient or HttpService to login function.

image

Environment

  • generator version: 5.3.0
  • node version: 8.11.3
  • npm version: 6.7.0
  • OS: Windows

Others: Same issue with:

generator work fine if i use Deprecated Http and i can’t use benefit of HttpService like cache.

Thank you for your great work at this generator.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
geekz-renocommented, Feb 10, 2019

@sinedied , @creal73 thanks for your help,

here my solution in case someone needed,

Create another service in my case MyAuthenticationService, and add to provider inside app.module

app.module,

image

my auth service,

image

and then you can use that service inside AuthenticationService

here is my AuthenticationService,

image

and be careful to use import from app/core or direct import service because it will make circular dependent.

1reaction
sinediedcommented, Feb 9, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Circular Dependency with two depending Services
HttpService now need the AccountService to get the Token for authenticate the request. This is causing a circular dependency error.
Read more >
NG0200: Circular dependency in DI detected while ... - Angular
This most commonly means removing or refactoring the dependencies to not be reliant on one another.
Read more >
How to fix the “Circular dependency detected” error in Google ...
The "Circular dependency detected" error in Google Sheets, is a very common error that can occur when using almost any formula.
Read more >
[Debugging] Circular dependency in DI detected - YouTube
In this video, you'll learn what the error " Circular dependency in DI detected" means, how to debug it, and prevent it from...
Read more >
Circular Dependencies in Spring - Baeldung
It can happen in Spring when using constructor injection. If we use other types of injections, we shouldn't have this problem since the ......
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