Injector Error “Provider parse errors: Cannot instantiate cyclic dependency!”

前端 未结 3 1995
一整个雨季
一整个雨季 2021-01-02 13:37

I tried to create an HttpInterceptor to add some headers for authorization to every http that happens. I need to get the headers from a service called

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 14:08

    Remove following from AuthService -

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

    The reason is - HttpClient using interceptor internally and interceptor using AuthService and AuthService is using HttpClient. thus it gives "cyclic dependency" error.

提交回复
热议问题