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

Add await to response.json() for async ApiResponse class #1725

Closed
wants to merge 2 commits into from

Conversation

Ekwinder
Copy link

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()

@Ekwinder
Copy link
Author

@microsoft-github-policy-service agree

@Skn0tt
Copy link
Member

Skn0tt commented Mar 31, 2025

The change looks good, but it's in the wrong place. This repository contains build outputs for the docs. Please open this PR against https://github.com/microsoft/playwright/blob/fffd87af1d65bc4d91ecf2eb47878f59b2ede514/docs/src/api/class-apiresponse.md#L16

@Ekwinder
Copy link
Author

Ekwinder commented Apr 6, 2025

Thanks @Skn0tt will raise a PR in the correct repo.

@Ekwinder Ekwinder closed this Apr 6, 2025
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