What is best way to refreshing token and retry api calls?

When you got 401 status you can use simply Axios interceptors to retry your latest API calls or if you use fetch also you can retry on the catch method.

Though my question is how can I retry my latest function that is including setState or maybe some logic after API calls? I mean that retrying API calls just try network call not that context we gonna try use APIs.

what Is the best practice to retry last calls?