axios interceptors not working as expected

I am trying to log out a user when I get a 401 response. By looking into how to achieve this, I can see I can do it with Axios interceptors, but it doesn’t seem to work for me. Is this the wrong way to use it or is there a better way to do what I need to do? Thank you

  axios.interceptors.response.use(
(response) => response,
(error) => {
  console.log(error);
  console.log("test");
}

);