Use retry kind of mechanism to reuse the token generation API from a third party service

I have to use a third party API for eg A, this A have some payload and it gives output as a authToken. This authToken when used in another API for eg B as payload header to fetch some details.
The B api which uses the token fetches the details upto when the token is not expired. After some time the B API gives response as Token expired, so when this happens, will have to again call the A API to give the new token and then use this new token in B and call it. I have node typescript code base.

Using request module of npm to first place a call to A then get the response, use that in B and after B gives the response check it if its expired again call both the APIs, A and B. But i am not sure as this is not looking a good approach to go with. IS there any other way to get this done?