如何忽略axios中的拦截器作为参数?

时间:2020-08-15 06:22:04

标签: javascript

我有axios拦截器,是否可以通过调用axios方法忽略一个请求的拦截器?

类似axios.post('/path/foo', null, { ignoreInterceptors: true } })

axios.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    return Promise.reject(error);
  }
);

1 个答案:

答案 0 :(得分:0)

代替:

axios.post('/path/foo')

您这样做:

const uninterceptedAxiosInstance = axios.create();
uninterceptedAxiosInstance.post('/path/foo')

没有任何东西可以拦截该请求。