Skip to content

Commit 9290fab

Browse files
committed
docs: Fix response body examples in README
- Corrected return format from {:ok, response} to response - Fixed response body access examples - Removed incorrect body_format option usage
1 parent 496187c commit 9290fab

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ IO.puts("Status: #{response.status}")
3434
text = HTTP.Response.text(response)
3535
{:ok, json} = HTTP.Response.json(response)
3636

37-
# Read response as stream (raw binary)
38-
{:ok, response} =
39-
HTTP.fetch("https://jsonplaceholder.typicode.com/posts/1", [
40-
options: [body_format: :binary]
41-
])
37+
# Read response body as raw binary
38+
response =
39+
HTTP.fetch("https://jsonplaceholder.typicode.com/posts/1")
4240
|> HTTP.Promise.await()
4341

44-
# response.body is now a binary stream you can process chunk by chunk
42+
# response.body contains the raw binary data
4543
binary_data = response.body
4644

4745
# POST request with JSON
@@ -116,14 +114,12 @@ Represents an HTTP response.
116114
text = HTTP.Response.text(response)
117115
{:ok, json} = HTTP.Response.json(response)
118116

119-
# Read response as stream (raw binary)
120-
{:ok, response} =
121-
HTTP.fetch("https://api.example.com/large-file", [
122-
options: [body_format: :binary]
123-
])
117+
# Access raw response body as binary
118+
response =
119+
HTTP.fetch("https://api.example.com/large-file")
124120
|> HTTP.Promise.await()
125121

126-
# Process binary response in chunks
122+
# response.body contains the raw binary response data
127123
binary_data = response.body
128124
```
129125

0 commit comments

Comments
 (0)