I am calling the two web API calls one after the other using the MSAL authentication token. While running the application, the first call is successful but the token value is lost on the second API call. The code that I am using is as shown below:

The main purpose of the code is to call the two simultaneous API calls using the MSAL token authentication.

Prasad RaveendranPosted Dec 29, 2023, 4:18 AM
Here's a basic example of how you might structure the calls to ensure sequential execution:
Replace
'first-api-endpoint','second-api-endpoint','your-api-scope', andmsalInstancewith your actual API endpoints, required scopes, and MSAL instance accordingly.Ensure that you've properly initialized your MSAL instance and configured it to request the necessary scopes. Also, handle token retrieval and refresh logic appropriately based on your application's requirements.
By following these steps and ensuring proper token handling and API call sequencing, you should be able to resolve the issue of losing the token value during the second API call in your React app.