I have created the shared Angular 8 library with service which is responsible for making http calls to fetch some data. library fine, when I import into my module I am getting below error
I have added so the service will be added to root.
@Injectable({
providedIn: 'root'
})
I have imported the service in AppModule Also, imported HttpClientModule
MyServiceProvider in lib
@Injectable({
providedIn: 'root'
})
export class MyServiceProvider {
private endpointUrl: string;
constructor(
private http: HttpClient,
private proxy: ProxyService) {
this.endpointUrl = this.proxy.getEndpoint();
}
getMydata() {
return this.http.post(this.endpointUrl).pipe(
map(response => {
console.log(response);
})
, catchError((error: HttpErrorResponse) => {
return throwError(error.error);
}));
}
}
in AppModule
import { MyServiceProvider } from 'my-lib';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(),
AppRoutingModule,
IonicStorageModule.forRoot()
],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
MyServiceProvider ---> (also tried without this)
],
bootstrap: [AppComponent]
})
export class AppModule { }
ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[MyServiceProvider -> HttpClient]: StaticInjectorError(Platform: core)[MyServiceProvider -> HttpClient]: