When an API returns a 401, I want to force logout the user. The following code is written inside a React Native Ignite project using Mobx
import { useStores } from "../../models"
this.apisauce.axiosInstance.interceptors.response.use(response => {
return response;
}, error => {
if (error.response.status === 401) {
useStores().authStore.reset()
}
return error;
})
The call to authStore.reset() doesn't happen, no error, no console.tron.log
, just nothing. Is there a better practice to capture 401 and trigger a mobx action? Without handling it at each individual action that calls into the API?