vue-request icon indicating copy to clipboard operation
vue-request copied to clipboard

[Feature Request] 对 CancelablePromise 的支持

Open liangguanhui0117 opened this issue 2 years ago • 0 comments

需求描述 Feature Description

对 CancelablePromise 的支持

https://github.com/alkemics/CancelablePromise

建议的解决方案 Proposed Solution

import CancelablePromise from 'cancelable-promise';

useRequest(new CancelablePromise((resolve, reject, onCancel) => {

  const controller = new AbortController();

  axios.get('/foo/bar', {
    signal: controller.signal
  }).then(resolve, reject);

  onCancel(() => {
    // 取消请求
    controller.abort()
  })

}))

liangguanhui0117 avatar Jun 30 '23 13:06 liangguanhui0117