I\'m working on a react application that consists of many API requests. The structure of the application is
When logging in, I\'m receiving a token on response and I
Yes you're partially correct, in case you cannot use refresh tokens (which should be given to maintain the login state ideally).
Use axios interceptors to intercept the response before it becomes an error like 401 which needs to be handled.
axios.interceptors.response.use(function (response) {
// 200 type responses, this should be left as it is
return response;
}, function (error) {
// Handle your 401 error, maybe the UI changes and removing from local storage
return Promise.reject(error);
});