javascript - 如何使用 Yelp API 获取业务 ID 数组的数据?
问题描述
我有一个包含企业 ID 的长数组,我想获取与该 ID 关联的每个业务数据。
尽管使用 axios 和正确的标头给了我结果,但由于以下错误/异常,我仍然会丢失一些数据:TOO_Many_Requests_Per_Second
.
我用于获取数据的代码如下:
const headers = {
Authorization: 'Bearer <token>',
'Content-Type': 'application/json',
};
data.maps(async (product : any) => {
const res = await axios.get(`${URLS.FETCH_BUSINESS_DETAILS}/${product.businessId}`, { headers });
});
解决方案
Yelp API 的开发人员文档包含有关此错误响应的以下信息:
每秒查询 (QPS) 速率限制
QPS 限制
如果您对 API 进行查询过快,您可能会收到带有 json 正文的 HTTP 429 错误:
{
"error": {
"code": "TOO_MANY_REQUESTS_PER_SECOND",
"description": "You have exceeded the queries-per-second limit for this endpoint.
Try reducing the rate at which you make queries."
}
}
如果您经常看到这些,请放慢调用 API 的速度。
推荐阅读
- angular - 重置行数据后,ag网格行数据正在更新
- android - 为什么我无法在 Xubuntu 上打开我的 Android Studio 项目?
- java - 如何导入我用java编写的类
- ios - 在 Swift / SwiftUI 中禁用向下滚动以关闭全屏封面
- ios - 使用命令行从 Flutter 生成 ipa 的任何方法?
- visual-studio-code - 在 vs-code 扩展中,如何将参数传递给 viewsWelcome.contents 中的命令
- java - Spring Boot 与 Datadog 的集成
- javascript - Web API 是 javascript 功能还是浏览器功能?
- reactjs - React-router URL 更改,但页面仍未更改
- installshield - Installshield 2015 关闭打开的浏览器