1

My axios instance is only hitting either the request interceptor or the response but not both. Take the following as an example.

const axiosInstance = axios.create({
    baseURL: GATEWAY_URL,
    headers: getDefaultHeaders(),
});

axiosInstance.interceptors.request.use(
    function (config) {
        console.log('before');
        return config;
    },
    function (error) {
        return Promise.reject(error);
    },
);

axiosInstance.interceptors.response.use(function (response) {
    console.log('after')
    return response;
  }, function (error) {
    return Promise.reject(error);
  });

I am getting before in the console. if I comment out the request interceptor then the response one logs.

Any ideas why?

user10045300
  • 387
  • 1
  • 4
  • 14

0 Answers0