简体   繁体   中英

How to set contentful.js api call rateLimit

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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