How do I extract the response body from an httpx GET request? or What's the best way to access the ht

22 Replies, 2243 Views

You’re not dumb—httpx is just picky! For the httpx get response body, here’s the deal:
- `.text`: String output (decoded).
- `.content`: Bytes (no decoding).
- `.json()`: If the response is JSON, this parses it.

Example:
```python
r = httpx.get("https://api.example.com/data")
data = r.json() # if it's JSON
```
Also, `r.status_code` is your best friend.

Messages In This Thread



Users browsing this thread: 1 Guest(s)