Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limited results #1

Closed
st3vo7 opened this issue May 19, 2022 · 3 comments
Closed

Limited results #1

st3vo7 opened this issue May 19, 2022 · 3 comments

Comments

@st3vo7
Copy link

st3vo7 commented May 19, 2022

site.subscriptions.get(callback_fun) doesn't fetch all subscriptions. Out of several thousand, I end up fetching only first 20.
Why is this happening and how to overcome it?

@natevw
Copy link
Owner

natevw commented May 20, 2022

The goal of Fermata and its plugins is to provide direct access to the underlying HTTP API. I don't know if this is the official documentation (perhaps Chargify got acquired?) but at https://docs.cloud-elements.com/home/chargify-api-documentation you can browse the available options for GET /subscriptions. One of them is is pageSize:

The number of resources to return in a given page

which I'm guessing might default to 20 if you don't provide it?

You could try to fetch a few extra site.subscriptions({pageSize:25}).get(callback_fun) and if that does change the results then you'll either want to increase the page size to a huge number (if their API allows you to do so) or you'll probably want to add handling to your code for their elements-next-page-token response header and make multiple requests like ({pageSize:250, nextPage: tokenFromPrevResponse}) until you've processed all the available objects.

Hope this helps!

@natevw natevw closed this as completed May 20, 2022
@st3vo7
Copy link
Author

st3vo7 commented May 20, 2022

Indeed, I made use of per_page and page parameters, as {per_page: 200, page: i}. For more info on those, I can refer others to read List Subscriptions part of the chargify documentation.

However, there were some issues to overcome in looping through all the pages in combination with the callback syntax. I reckon, it would be much easier if the library would use async/await syntax.

Thanks for thorough reply.

@natevw
Copy link
Owner

natevw commented May 23, 2022

Thanks, agree that async support would be useful! No real blocker at this point iirc, just haven't circled back to working out an overall "Fermata v2" yet. (For reference, looks like my latest notes on this specifically were at natevw/fermata#49 (comment).)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants