79411467

Date: 2025-02-04 11:16:04
Score: 0.5
Natty:
Report link

You probably have an /api/user or /api/me endpoint. Why not do it there instead of creating a dummy endpoint?

Another option is to use axios interceptors: https://axios-http.com/docs/interceptors

axios.interceptors.response.use(
  (response) => response,
  (error) => {
    if (error.response.status === 401) {
      dispatch(logoutUser()) // probably needs a debounce
    }
    return Promise.reject(error)
  })
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: shotor