cloudflare / node-cloudflare

Node.js API for Client API
https://cloudflare.github.io/node-cloudflare/
Other
335 stars 92 forks source link

Pagination Support #58

Closed terinjokes closed 7 months ago

terinjokes commented 4 years ago

The Cloudflare API is pretty consistent in how it supports pagination. It would be nice to have to support asynchronously fetching new pages.

34 #37

depombo commented 3 years ago

That would be great!

ririko5834 commented 3 years ago

Can you fetch all DNS records in one request without pagination?

terinjokes commented 3 years ago

Not at this time.

mjpoo commented 2 years ago

I would also be very grateful if either there could be larger paging or pagination as at the moment we are having to store all the zone IDs in our own database because zones.browse() only returns the first 20 zones.

terinjokes commented 2 years ago

The last parameter, after all the URL parameters and body, is and optional query parameter object, so you should be able to pass { page: 2 }

mjpoo commented 2 years ago

Ohh that is handy @terinjokes . I've tried that out and it works like a charm. Does that mean that any browse method will accept an options object in the same manner and that we could also pass an options object to a read method after the required parameters? e.g. pageRules.read('abc123', { status: active }).

terinjokes commented 2 years ago

All the methods should allow setting query parameters as the last (optional) function parameter, though the browse and read ones are probably the most useful.

mjpoo commented 2 years ago

Thanks for confirming that @terinjokes . The biggest benefit is that I can simply return a named zone pageRules.browse( { name: 'foo.com' } ) effectively using the browse method as a read method.

For the benefit of others here are all the optional parameters you could pass into the zones.browse() method.