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

Not getting response object in Pagination #165

Open
Dminor7 opened this issue Nov 2, 2020 · 1 comment
Open

Not getting response object in Pagination #165

Dminor7 opened this issue Nov 2, 2020 · 1 comment

Comments

@Dminor7
Copy link

Dminor7 commented Nov 2, 2020

Hi,
I am not getting response object when using the pages() method.
In my response I get pagination details as below:

{
    "response": [],
    "pagination":{
        "current": 1,
        "previous": null,
        "next": 2,
        "per_page": 100,
        "pages": 2
    }
}

The request object contains below details:

{
    "api_key": "****",
    "sort": "updated_at",
    "order": "asc",
    "page": 1,
    "per_page": 10
}

I had implemented the get_iterator_next_requests_kwargs function accordingly which works correctly-

def get_iterator_next_request_kwargs(
        self, iterator_request_kwargs, response_data, response
    ):
        paging = response_data.get('pagination')
        if not paging:
            return
        next_page = paging.get("next")
        if next_page:
            params = iterator_request_kwargs["params"]
            params["page"] = next_page
            iterator_request_kwargs["params"] = params
            return iterator_request_kwargs

When iterating over the resource like:

resp = api.resource().get(params=params)
for r in resp().pages(max_pages=2):
        print(r().data)

I am getting below output as type class str, instead of the response object

response
pagination
response
pagination

Am I doing something wrong here? Please do help. Thanks

@filipeximenes
Copy link
Contributor

🤔 that looks pretty standard. I can't spot any issues in the things you sent.

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