I am using dynamic token to fetch APIs. How can I handle 401 status code form API

I am using dynamic token to fetch APIs. How can I handle 401 status code form API.
Under this scenario I would like to refresh my token and retry