[英]How to fix Cannot read property 'axios-retry' of undefined
I've been facing this issue on axios and axios retry Error我一直在 axios 和 axios 重试错误上遇到这个问题
TypeError: Cannot read property 'axios-retry' of undefined
at getCurrentState (index.js:118)
at index.js:264
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:241
at _callTimer (JSTimers.js:112)
at _callImmediatesPass (JSTimers.js:166)
at MessageQueue.callImmediates [as _immediatesCallback] (JSTimers.js:411)
at MessageQueue.__callImmediates (MessageQueue.js:388)
at MessageQueue.js:132
Package.json Package.json
"axios": "1.2.0",
"axios-retry": "3.3.1",
axiosRetry(axios, {
retries: 0,
retryDelay: count => count * 1000,
},
})
const fetchCall = (url, requestInfo) =>
axios({
method: requestInfo.method,
url,
timeout: requestInfo.timeout,
headers: requestInfo.headers,
data: requestInfo.body,
'axios-retry': {
retries:1
},
})
I've tried to upgrade both packages axios(0.18.1 -> 1.2.0) and axios(3.1.9 -> 3.3.1) retry我尝试升级两个包 axios(0.18.1 -> 1.2.0) 和 axios(3.1.9 -> 3.3.1) 重试
I'm not sure if you can add retry dynamically though.我不确定你是否可以动态添加重试。 Instead try to create a client and use configuration as you did before, something like that:而是像以前一样尝试创建一个客户端并使用配置,就像这样:
import axios from 'axios'
import axiosRetry from 'axios-retry'
const axiosClient = axios.create()
axiosRetry(axiosClient, {
retries: 0,
retryDelay: count => count * 1000,
},
})
export default axiosClient
and then just use this client everything and not the one imported from a package directly然后只使用这个客户端的一切,而不是直接从 package 导入的那个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.