Add axios-retry for Vercel integration for now

This commit is contained in:
Tuan Dang
2023-02-24 00:52:43 +07:00
parent 7ce9c816c5
commit b906048ea1
4 changed files with 87 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
import axios from 'axios';
import axiosRetry from 'axios-retry';
const axiosInstance = axios.create();
// add retry functionality to the axios instance
axiosRetry(axiosInstance, {
retries: 3,
retryDelay: (retryCount) => retryCount * 1000, // delay between retries (in milliseconds)
retryCondition: (error) => {
// only retry if the error is a network error or a 5xx server error
return axiosRetry.isNetworkError(error) || axiosRetry.isRetryableError(error);
},
});
export default axiosInstance;