Uncaught (in promise) useRequest has caught the exception, if you need to handle the exception yourself, you can set options.throwOnError to true.
const { run } = useRequest(fetch, { manual: true, throwOnError: true });
run.catch(handle); // 如果使用 pollingInterval 的话,这招也会失效
I think just return at this line would work better. No one would like to catch these errors.
diff --git a/node_modules/@ahooksjs/use-request/es/useAsync.js b/node_modules/@ahooksjs/use-request/es/useAsync.js
index 9783cb8..fa15271 100644
--- a/node_modules/@ahooksjs/use-request/es/useAsync.js
+++ b/node_modules/@ahooksjs/use-request/es/useAsync.js
@@ -199,7 +199,7 @@ function () {
console.error(error); // eslint-disable-next-line prefer-promise-reject-errors
+ return;
return Promise.reject('useRequest has caught the exception, if you need to handle the exception yourself, you can set options.throwOnError to true.');
})["finally"](function () {
if (currentCount === _this.count) {
diff --git a/node_modules/@ahooksjs/use-request/lib/useAsync.js b/node_modules/@ahooksjs/use-request/lib/useAsync.js
index 43ba293..91411e3 100644
--- a/node_modules/@ahooksjs/use-request/lib/useAsync.js
+++ b/node_modules/@ahooksjs/use-request/lib/useAsync.js
@@ -221,7 +221,7 @@ function () {
console.error(error); // eslint-disable-next-line prefer-promise-reject-errors
+ return;
return Promise.reject('useRequest has caught the exception, if you need to handle the exception yourself, you can set options.throwOnError to true.');
})["finally"](function () {
if (currentCount === _this.count) {
$ yarn add ahooks@next
We have fixed this problem in the v3.0 version, and the alpha has been released.
Welcome to try.
Doc:https://ahooks-next.surge.sh/
Source Code:https://github.com/alibaba/hooks/tree/next
Install v3.0
$ npm install --save ahooks@next
$ yarn add ahooks@next