useRequest
Error Retry
The API useRequest
Error Retry
By setting options.retryCount, set the number of error retries, useRequest will retry after it fails.
const { data, run } = useRequest(getUsername, {
retryCount: 3,
});As in the example code above, after the request is failed, it will retry 3 times.
You can type text in the input box below and click the Edit button to experience the effect
API
Options
| Property | Description | Type | Default |
|---|---|---|---|
| retryCount | The number of retries. If set to -1, it will try again indefinitely. | number | - |
| retryInterval |
| number | - |
Remark
options.retryCount,options.retryIntervalsupport dynamic changes.cancelcan cancel the ongoing retry behavior.