繁体   English   中英

如何修复无法读取未定义的属性“axios-retry”

[英]How to fix Cannot read property 'axios-retry' of undefined

我一直在 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

      "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
          },
    })

我尝试升级两个包 axios(0.18.1 -> 1.2.0) 和 axios(3.1.9 -> 3.3.1) 重试

我不确定你是否可以动态添加重试。 而是像以前一样尝试创建一个客户端并使用配置,就像这样:

import axios from 'axios'
import axiosRetry from 'axios-retry'

const axiosClient = axios.create()

axiosRetry(axiosClient, {
    retries: 0,
    retryDelay: count => count * 1000,
  },
})

export default axiosClient

然后只使用这个客户端的一切,而不是直接从 package 导入的那个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM