arnaudleclerc / ng-azure-maps

Angular wrapper around azure maps
MIT License
16 stars 14 forks source link

Loading script through APP_INITIALIZER fails on interceptor #76

Open yuriip-mancofi opened 1 year ago

yuriip-mancofi commented 1 year ago

When trying to dynamically set the subscription key through the APP_INITIALIZER, we need to use a setAzureMapsConfiguration function in order to provide azure maps with configured element providers: [ { provide: APP_INITIALIZER, useFactory: () => new Promise((res, rej) => {... setAzureMapsConfiguration()}), deps: [...], multi: true } ], However, this would set { provide: AZUREMAPS_CONFIG, useValue: configuration }, AZUREMAPS_CONFIG to have value of undefined, as we are not providing it directly through AzureMapsModule.forRoot({ authOptions: environment.authOptions }) or overriding it in the app module with { provide: AZUREMAPS_CONFIG, useValue: { authOptions: environment.authOptions } } Without this token the AtlasRestAuthenticationInterceptor is failing, because if loaded asynchronously, the token is never set in the first place. I assume that we would still need to provide this token in order to make interceptor work. So that, it wouldn't really work with APP_INITIALIZER