Let’s say I have 10 different backend calls being made, each one needs authorisation. At some point one of these will fail and return a 401 error. How do I add the logic to redirect to the login page when this happens? My logged in state is controlled by useState so should I use a context and then check in each of the 10 requests that if the error is 401 set authorised to false (have a useEffect in the root of the app listening for loggedIn state changes).
Or is there a cleaner approach without the need to repeat the error handling for each individual request?