问题
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