Error Retry
Transient errors are common in applications, such as temporary disconnection between the interface server and the database server, or temporary network failure on the client side. These failures often self-correct in a short time, and the request may succeed if attempted after an appropriate delay.
Now you can let VueRequest handle this for you with a simple configuration. Just provide an errorRetryCount
to tell us the number of retries. As shown in the example below:
ErrorRetryCount
import { useRequest } from 'vue-request';
const { data } = useRequest(getUser, {
errorRetryCount: 5, // it will retry 5 times
});
ErrorRetryInterval
Tips
By default, we will use the Exponential Backoff Algorithmopen in new window to calculate the appropriate interval time for you.
Of course, you can also provide errorRetryInterval
to set the retry interval time.
import { useRequest } from 'vue-request';
const { data } = useRequest('api/users', {
errorRetryCount: 5, // it will retry 5 times
errorRetryInterval: 3 * 1000, // The retry interval is 3 seconds
});