Skip to content

Commit

Permalink
Rest API: Ends pagination if next page path is not in response.json() (
Browse files Browse the repository at this point in the history
  • Loading branch information
willi-mueller authored and burnash committed Feb 19, 2024
1 parent c6015fe commit d4a3160
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sources/rest_api/paginators.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ def __init__(
self._records_accessor = create_nested_accessor(records_key)

def update_state(self, response: Response):
self.next_reference = self._next_key_accessor(response.json())
try:
self.next_reference = self._next_key_accessor(response.json())
except KeyError:
self.next_reference = None

def extract_records(self, response: Response) -> Any:
return self._records_accessor(response.json())
Expand Down

0 comments on commit d4a3160

Please sign in to comment.