How to set contentful.js api call rateLimit

帅比萌擦擦* 提交于 2019-12-11 10:45:50

问题


I have following code:

contentfulMgmt.createClient({
                accessToken: sourceSpace.accessCode,
                rateLimit: 1,
                secure: true,
                retryOnTooManyRequests: true,
                maxRetries: 5
            });

How to set api call rate?

I have seen it in their github project but i am unable to make it work.

For ref:

rate-limit: https://github.com/contentful/contentful-management.js/blob/master/lib/rate-limit.js

contentful-management: https://github.com/contentful/contentful-management.js

They have added index.js file in the project but how to use it. Kindly help.

Please help. Thanks


回答1:


All you should need to do is to specify the rateLimit property. That property defines maximum amount of requests per second the library will try to send. The default value is 6, and you probably won't want to go much higher than 10.

Be aware however, that the server also limits the amount of requests per second and per hour, so if you set that number too high you might start getting a 429 error from the server.

The library will try to recover from that by default (retryOnTooManyRequests). If all the max retries are exhausted then you've probably reached your rate limit per hour.



来源:https://stackoverflow.com/questions/36035199/how-to-set-contentful-js-api-call-ratelimit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!