This is a naive work-around to the glitchy rate limiter of the current Webflow API. Any suggestions to optimizations is much appreciated.
It's a wrapper to your existing webflow-api functions, where you define two parameters:
- a collection ID and
- the function you want to call
If you have reached the rate limit this wrapper will handle the error and try to reset the rate limiter count by basically spamming until a new pool of requests has been granted.
Pro: easy to setup and integrate into existing solution Con: your script might time-out if the Webflow API does not provide a new pool fast enough
This was your function before:
const getCollection = async ({ collectionId }) =>
await webflow.items({ collectionId });
... and this is your function with this wrapper:
const getCollection = async ({ collectionId }) =>
await webflowRateLimiterWorkaround({
collectionId,
callback: async () => await webflow.items({ collectionId }),
});