`useFetch ` | Support for custom abort reason
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.
| 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.