Skip to content

Commit 6a32d03

Browse files
authored
[doc] add the empty parameter for text in readme.md (#157)
Following the #66 , the PR is to add the empty parameter list to calls to geny's text() method. Because when I try to run with scala-3.4.1 with `r.text` , it fails with ``` [info] compiling 1 Scala source to /tmp/s/target/scala-3.4.1/classes ... [error] -- [E100] Syntax Error: /tmp/s/src/main/scala/Main.scala:7:5 ------------------- [error] 7 | r2.text [error] | ^^^^^^^ [error] | method text in trait ByteData must be called with () argument [error] | [error] | longer explanation available when compiling with `-explain` [error] one error found [error] (Compile / compileIncremental) Compilation failed [error] Total time: 5 s, completed May 16, 2024, 12:35:38 PM ```
1 parent f8898cc commit 6a32d03

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

readme.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ r.statusCode
8080
r.headers("content-type")
8181
// Buffer("application/json; charset=utf-8")
8282

83-
r.text
83+
r.text()
8484
// {"login":"lihaoyi","id":934140,"node_id":"MDQ6VXNlcjkzNDE0MA==",...
8585
```
8686

@@ -154,11 +154,11 @@ r.headers("content-type")
154154

155155
As seen earlier, you can use `.statusCode` and `.headers` to see the relevant
156156
metadata of your HTTP response. The response data is in the `.data` field of the
157-
`Response` object. Most often, it's text, which you can decode using the `.text`
157+
`Response` object. Most often, it's text, which you can decode using the `.text()`
158158
property as shown below:
159159

160160
```scala
161-
r.text
161+
r.text()
162162
// [{"id":"7990061484","type":"PushEvent","actor":{"id":6242317,"login":...
163163
```
164164

@@ -244,7 +244,7 @@ the server:
244244
```scala
245245
val r = requests.get("https://api.github.com/events")
246246

247-
val json = ujson.read(r.text)
247+
val json = ujson.read(r.text())
248248

249249
json.arr.length
250250
// 30
@@ -387,7 +387,7 @@ r.cookies
387387

388388
val r2 = requests.get("https://httpbin.org/cookies", cookies = r.cookies)
389389

390-
r2.text
390+
r2.text()
391391
// {"cookies":{"freeform":"test"}}
392392
```
393393

@@ -500,7 +500,7 @@ val r = s.get("https://httpbin.org/cookies/set?freeform=test")
500500

501501
val r2 = s.get("https://httpbin.org/cookies")
502502

503-
r2.text
503+
r2.text()
504504
// {"cookies":{"freeform":"test"}}
505505
```
506506

@@ -519,12 +519,12 @@ val s = requests.Session(
519519

520520
val r1 = s.get("https://httpbin.org/cookies")
521521

522-
r1.text
522+
r1.text()
523523
// {"cookies":{"cookie":"vanilla"}}
524524

525525
val r2 = s.get("https://httpbin.org/headers")
526526

527-
r2.text
527+
r2.text()
528528
// {"headers":{"X-Special-Header":"omg", ...}}
529529
```
530530

@@ -558,7 +558,7 @@ val r = requests.get(
558558
params = Map("q" -> "http language:scala", "sort" -> "stars")
559559
)
560560

561-
r.text
561+
r.text()
562562
// {"login":"lihaoyi","id":934140,"node_id":"MDQ6VXNlcjkzNDE0MA==",...
563563
```
564564
```scala

0 commit comments

Comments
 (0)