简体   繁体   English

如何使用 Yelp API 获取业务 ID 数组的数据?

[英]How to fetch the data of an array of business ids using Yelp API?

I have an long array containing ids of businesses and I want to fetch each business data associated with the id.我有一个包含企业 ID 的长数组,我想获取与该 ID 关联的每个业务数据。

Although using axios and the right headers gives me the result, I still get some of the data missing due to the following error/exception: TOO_Many_Requests_Per_Second .尽管使用 axios 并且正确的标题给了我结果,但由于以下错误/异常,我仍然会丢失一些数据: TOO_Many_Requests_Per_Second

The code I use for fetching the data is as follows:我用于获取数据的代码如下:

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      });
      });

The developer docs for the Yelp API has the following information about this error response: Yelp API 的开发人员文档包含有关此错误响应的以下信息:

Queries-Per-Second (QPS) Rate Limiting每秒查询 (QPS) 速率限制

QPS Limit QPS 限制

If you make queries against the API too quickly, you may get HTTP 429 errors with the json body:如果您过快地对 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."
    }
}

If you are seeing these regularly, please slow down the rate at which you are making calls to the API.如果您经常看到这些,请放慢您拨打 API 的速度。

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

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