I am facing an issue with my TypeScript function where the code after the promise is not being executed. The function is supposed to set up a protected resource map but it seems like Chrome is skipping over this part of the code entirely.
export function MSALInterceptorConfigFactory(jsonAppConfigService: JsonAppConfigService): MsalInterceptorConfiguration {
const protectedResourceMap = new Map<string, Array<string>>();
const resource = "asdfd";
jsonAppConfigService.loadConfig()
.toPromise()
.then(()=>{
protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read', 'mail.read']);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method1`, [resource]);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method2`, [resource]);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method3`, [resource]);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method4`, [resource]);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method5`, [resource]);
protectedResourceMap.set(`${jsonAppConfigService.apiEndPoint}api/method6`, [resource]);
}
);
return {
interactionType: InteractionType.Redirect,
protectedResourceMap
};
}
Could someone provide some guidance on why this code may not be executing as expected?
Also, just to provide context, this function is located in the app.module.ts file of a web app and has been added to the NgModule section as shown below:
{
provide: MSAL_INTERCEPTOR_CONFIG,
deps: [JsonAppConfigService],
useFactory: MSALInterceptorConfigFactory,
},
Thank you in advance for any help.