reactjs - 在 ReactJS 中每 30 秒调用一次 API
问题描述
我试图每 30 秒调用一次 api。我已经尝试用 setInterval 来做,但它并没有真正奏效。
有什么建议么?
componentDidMount() {
const {getCurrencies, setPageCount,loadData} = this.props.actions
agent
.get('https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=XXX')
.then(res => {
getCurrencies(res.body.data)
setPageCount()
})
.catch(err => {
console.log(err)
});
}
解决方案
推荐阅读
- python-3.x - 本地 python 连接到远程服务器上的 Spark-SQL
- css - 使 ag-grid 以 100% 的角度页面高度的方法
- linux - awk 脚本无法与 gsub 一起正常工作 $10
- java - 如何更改擦除或更新文本、时间或输出文本
- scala - Spark 数据框列名无法识别
- node.js - 在 heroku 上部署 MERN 会导致意外错误
- javascript - 我可以使用引导弹出框显示带有标题(文本和图像)和正文(文本)的内容吗?
- drop-down-menu - 如何使用 MS Word 下拉列表来指定 INCLUDETEXT 的范围?
- android - android错误找不到类JobSchedular
- java - 如何使用 JNA(打印机和作业)从 WinspoolUtil 和 Winspool 获取 JobInfo2?