Skip to content

Commit

Permalink
Handle missing 'next_page' key in JSON response
Browse files Browse the repository at this point in the history
Updated the GetPostsResponse class to use the get() method for accessing 'next_page' in the response JSON, ensuring compatibility with responses that may not include this key. This change prevents potential KeyError exceptions.
  • Loading branch information
Pdzly committed Aug 3, 2024
1 parent d4fe6de commit ea46645
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plemmy/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class GetPostsResponse(object):
def __init__(self, api_response: requests.Response) -> None:
response = api_response.json()
self.posts = [PostView(p) for p in response["posts"]]
self.next_page = response["next_page"]
self.next_page = response.get("next_page")


class GetRepliesResponse(object):
Expand Down

0 comments on commit ea46645

Please sign in to comment.