-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
enhancementNew feature or requestNew feature or request
Description
Clear and concise description of the problem
Currently abort does not support parameter settings, and it is difficult to distinguish whether abort is due to timeout or other custom abort.
vueuse/packages/core/useFetch/index.ts
Lines 397 to 407 in 0e10eb2
const abort = () => { | |
if (supportsAbort) { | |
controller?.abort() | |
controller = new AbortController() | |
controller.signal.onabort = () => aborted.value = true | |
fetchOptions = { | |
...fetchOptions, | |
signal: controller.signal, | |
} | |
} | |
} |
Suggested solution
abort function add reason Parameters , such like
const abort = (reason?: any) => {
if (supportsAbort) {
controller?.abort(reason)
controller = new AbortController()
controller.signal.onabort = () => aborted.value = true
fetchOptions = {
...fetchOptions,
signal: controller.signal,
}
}
}
Then we can handle it uniformly in onFetchError
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request