Open jsgoupil opened 6 years ago
here is the scenario how we like to use HttpClientInMemoryWebApiModule
with root and feature modules:
Best practice is not to inject HttpClientModule
twice. but in-memory-web-api
is forcing us to do so.
HttpClientInMemoryWebApiModule forRoot
at Root Module
https://github.com/xmlking/nx-starter-kit/blob/master/apps/default/src/app/core/core.module.ts#L13
HttpClientInMemoryWebApiModule for forFeature
Module
https://github.com/xmlking/nx-starter-kit/blob/master/libs/dashboard/src/dashboard.module.ts#L23
@wardbell While not hyper critical, I still think this issue has merit to at least be discussed.
Functionally, the issue exists because of having to import HttpClientModule in feature modules in order for the Mock API's parseRequestUrl to get picked up.
When trying to register the
InMemoryDbService
it is required to have theHttpClientModule
loaded as a sibling. This is problematic when theHttpInterceptor
s are attached to the rootHttpClientModule
. In a forFeature (loadChildren
route), my root interceptors will be ignored.I understand my scenario might be a little out of scope for handling basic GET/POST. But if I reduce it to the bare bone, this is what I get.
app.module
admin.module
My ugly workaround is to load MyHttpClientModule with my interceptors everywhere where I add the HttpClientInMemoryWebApiModule.