How to handle API path for Web and Ionic. I have my all api requests in libs. And Web part doesn't need IP address where as Ionic App needs IP address. How do I differ in between them?
You could have an APIModule that takes an argument for the address, and initialize it in both your Web app and Ionic app.
libs/api/src/api.module.ts
export const API_HOST = new InjectionToken('API_HOST');
@NgModule()
export class ApiModule {
static forRoot(host: string) {
return {
ngModule: ApiModule,
providers: [{
provide: API_HOST,
useValue: host
}]
}
}
}
apps/mobile/src/app.module.ts
imports: [
ApiModule.forRoot(SOME_IP_ADDRESS)
]
apps/web/src/app.module.ts
imports: [
ApiModule.forRoot('')
]
Most helpful comment
You could have an APIModule that takes an argument for the address, and initialize it in both your Web app and Ionic app.
libs/api/src/api.module.ts
apps/mobile/src/app.module.ts
apps/web/src/app.module.ts