I have two fetch calls on my typescript code, one to get access token and other to call the actual API.

I need to set time out(1 second) for second API call. If timed out, a retry should be made and while retrying, access token should be retrieved again.

What is the best approach to achieve this?