Created
September 29, 2021 13:02
-
-
Save rockink/679a52c97da80e96a8fad032d85ee977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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