Skip to content

Instantly share code, notes, and snippets.

@rockink
Created September 29, 2021 13:02
Show Gist options
  • Save rockink/679a52c97da80e96a8fad032d85ee977 to your computer and use it in GitHub Desktop.
Save rockink/679a52c97da80e96a8fad032d85ee977 to your computer and use it in GitHub Desktop.
def get_post_comments(post_id: int) -> List[BlogPost]:
SERVER_ENDPOINT = "https://jsonplaceholder.typicode.com/comments"
response = requests.get(
SERVER_ENDPOINT,
params=dict(postId=post_id) # NEW CONCEPT: notice the post id there?
)
if response.status_code == 200:
# NEW CONCEPT: read the for loop in 1 line. Note how everything wires up.
return response.json()
print(get_post_comments(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment