Skip to content

Not getting response object in Pagination #165

Description

@Dminor7

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions