📜  如何使用 axios 取消令牌取消请求 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:52.549000             🧑  作者: Mango

代码示例1
const source = CancelToken.source();
  const timeout = setTimeout(() => {
    source.cancel();
    // Timeout Logic
  }, 10000);
  
  axios.get(ip + '/config', {cancelToken: source.token}).then((result) => {
    // Clear The Timeout
    clearTimeout(timeout);

    // Handle your response
  });