沃梦达 / IT编程 / 移动开发 / 正文

#axios 拦截器 取消请求,#axios interceptors.request cancel a http request #使用axios在request拦截器中取消请求

instance.interceptors.request.use(config = {/* some logic */const CancelToken = Axios.CancelToken;return {...config,cancelToken: new CancelToken((cancel) = cancel(Cancel repeated request))};});

instance.interceptors.request.use(config => {
  /* some logic */
  const CancelToken = Axios.CancelToken;
  return {
    ...config,
    cancelToken: new CancelToken((cancel) => cancel('Cancel repeated request'))
  };
});

本文标题为:#axios 拦截器 取消请求,#axios interceptors.request cancel a http request #使用axios在request拦截器中取消请求