Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add await to response.json() for async ApiResponse class example #35503

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

Ekwinder
Copy link
Contributor

@Ekwinder Ekwinder commented Apr 6, 2025

The current async APIResponse class documentation in API Reference has an incorrect line in the example -

assert response.json()["name"] == "foobar"

As the async APIResponse response.json() returns a coroutine, this line will raise a TypeError: 'coroutine' object is not subscriptable exception.

Replacing it with

json_data = await response.json()
assert json_data["name"] == "foobar"

will solve this and show the correct way to use response.json()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants