Skip to content

Commit

Permalink
Allow passing starting cursor in paginated helper (#222)
Browse files Browse the repository at this point in the history
* Allow passing starting cursor in paginated helper

Allow passing next_cursor to the paginated api to set the starting cursor.

* Take a slightly different approach

---------

Co-authored-by: ramnes <[email protected]>
  • Loading branch information
smarttommyau and ramnes authored Dec 25, 2023
1 parent 3e2a51f commit c1faf0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notion_client/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def iterate_paginated_api(
function: Callable[..., Any], **kwargs: Any
) -> Generator[List[Any], None, None]:
"""Return an iterator over the results of any paginated Notion API."""
next_cursor = None
next_cursor = kwargs.pop("start_cursor", None)

while True:
response = function(**kwargs, start_cursor=next_cursor)
Expand All @@ -53,7 +53,7 @@ async def async_iterate_paginated_api(
function: Callable[..., Awaitable[Any]], **kwargs: Any
) -> AsyncGenerator[List[Any], None]:
"""Return an async iterator over the results of any paginated Notion API."""
next_cursor = None
next_cursor = kwargs.pop("start_cursor", None)

while True:
response = await function(**kwargs, start_cursor=next_cursor)
Expand Down

0 comments on commit c1faf0a

Please sign in to comment.