Issues with execution of promise code in Angular 11 post then method not triggering

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.

Answer №1

Shoutout to Moufeed Juboqji for the help. I've learned the importance of using try/catch and examining the catch block to handle exceptions. Thanks to that, I was able to identify and resolve the issue causing the exception.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to log out of OIDC-client due to an error: end session endpoint not found

Currently, I am in the process of setting up a code flow with Auth0 as my chosen identity provider. Successfully, the sign-in process functions well and I receive a valid token from Auth0. However, I am encountering an issue when attempting to sign out ...

Is it a good idea to separate TypeScript types into their own package?

In my React/TypeScript application, I have approximately 100 files where various types are declared. I am looking for a simpler and more automated approach to extract all these types into a separate package. Is there a method other than manually copying ...

Retrieving data from array services in Angular using Typescript

I need help retrieving data from an array in my services using a get function. I've tried using the .filter and .find functions, but I'm struggling with the execution and haven't been able to retrieve the data successfully. I know this may b ...

Having trouble navigating with router.navigate and utilizing local storage?

I have a code that utilizes router.navigate to direct the user to a specific location abrirLista(categoria, id) { localStorage.setItem('categName', JSON.stringify(categoria)); const slug = slugify(categoria); this.router.navigate(['/lista&ap ...

I am looking for guidance on removing the bottom line from the ionic 4 segment indicator. Any advice or tips on

.segment-button-indicator { -ms-flex-item-align: end; align-self: flex-end; width: 100%; height: 2px; background-color: var(--indicator-color); opacity: 1; } I am a beginner in hybrid app development and ...

Concealing hyperlinks depending on authentication status in Angular 2

How can I hide the Navbar links instantly based on user authentication without the need for a page refresh? SampleComponent.html <div class="content"> <md-toolbar> <md-icon>menu</md-icon> <span class="fill-s ...

Is it possible for Angular version 15 to function without needing to migrate to material

Can anyone clarify whether material migration is necessary when upgrading from Angular v14 to v15? The Angular upgrade guide mentions that old(v14) material modules can still be used by utilizing legacy modules, so is it mandatory to migrate? "In the new ...

An error was detected in the card-module.d.ts file located in the node_modules folder within the @angular/material/card/typings directory

Currently, I am working on an angular project using Visual Studio Code as my text editor. When attempting to open the project with 'npm start', an error occurred. The specific error message is: ERROR in node_modules/@angular/material/card/typing ...

Formula for a distinct conclusion of written words

Can I restrict input to only letters and numbers, with words like xls, xlsx, json, xml always appearing at the end of the line? This is the pattern I am currently using: Validators.pattern(/^[a-zA-Z0-9]+$/) ...

Executing test units in Angular

While setting up unit tests for my Angular app, I expect the ngInit function to be called. Component.ts: ngOnInit() { this.topToolBarService.change.subscribe(customer => { this.filter.customerid = customer; this.customerid = customer; ...

Leveraging the OpenLayers Map functionality within an Angular service

I am curious to learn if there is a way to utilize a service in Angular for creating an OpenLayers map and then passing that service to other components to update the map based on interactions within those components. I have outlined my approach below. Des ...

Having trouble with CSS values not being applied to dynamically injected HTML div elements in Angular 4?

Link to Codepen My Angular calendar application runs smoothly without any errors. However, I am encountering an issue where the CSS styles are not being applied to the page. When I implemented this separately, everything worked fine. But as soon as I inc ...

Tips for accessing query parameters within an APP_INITIALIZER service in Angular 4

I have created a unique custom ConfigService designed to retrieve configuration details before the Angular application initializes. The code snippet below is implemented within app.module.ts and successfully loads the configurations prior to the app start ...

We were unable to identify any Next.js version in your project. Please ensure that the `"next"` package is installed in either the "dependencies" or "devDependencies" section

My attempt to deploy a Next app using the Vercel CLI has hit a roadblock. After running vercel build with no errors, I proceeded to deploy with vercel deploy --prebuilt, which also went smoothly. However, when trying to move the project from the preview en ...

Currently focused on developing vertical sliders that can be manipulated by dragging them up or down independently

https://i.stack.imgur.com/NgOKs.jpg# I am currently working on vertical sliders that require dragging up and down individually. However, when I pull on the first slider, all sliders move together. The resetAllSliders button should also work independently, ...

Issue: TypeScript is throwing an error of type TypeError because it is unable to read the property "push" of an undefined

I am encountering a common issue while working with TypeScript. The error message I am receiving is: ERROR TypeError: Cannot read property 'push' of undefined In my code, I have defined a model called EmailModel: export class EmailModel { ...

The seamless union of Vuestic with Typescript

Seeking advice on integrating Typescript into a Vuestic project as a newcomer to Vue and Vuestic. How can I achieve this successfully? Successfully set up a new project using Vuestic CLI with the following commands: vuestic testproj npm install & ...

How to display document files (.doc or .docx) using a byte array in Angular 4

I am facing a challenge in viewing all the attachments submitted by users. While I can easily view PDF and image files, I seem to have trouble with files having .doc or .docx extensions. Here is my current approach: let file = null; if (extension === &a ...

Declare the push method within the Countly.q array in a TypeScript declaration file

Is there a way to declare Countly push add_event method in the following manner? Countly.q.push(['add_event',{ "key":"action_open_web", }]); I attempted to do this inside a declaration file (.d.ts) but it did not work. Here ...

Is there a way to display the text that has been selected?

I would like to display the text of a clicked link in an empty div element. Can someone help me achieve this? Thank you. <div></div> <span>link one</span> <span>link two</span> <span>link three</span> ...