Skip to content

Commit 11a9787

Browse files
authored
Update the sttp example so that it compiles using v3 (#76)
1 parent 0aa7e88 commit 11a9787

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

readme.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,16 @@ httpClient.expect[String](request)
615615
```
616616
```scala
617617
// sttp
618-
import com.softwaremill.sttp._
618+
import sttp.client3._
619619

620-
val sort: Option[String] = None
621-
val query = "http language:scala"
620+
val request = basicRequest.response(asStringAlways)
621+
.get(uri"https://api.github.com/search"
622+
.addParams(Map("q" -> "http language:scala", "sort" -> "stars")))
622623

623-
// the `query` parameter is automatically url-encoded
624-
// `sort` is removed, as the value is not defined
625-
val request = sttp.get(uri"https://api.github.com/search/repositories?q=$query&sort=$sort")
624+
val backend = HttpURLConnectionBackend()
625+
val response = backend.send(request)
626626

627-
implicit val backend = HttpURLConnectionBackend()
628-
val response = request.send()
629-
630-
// response.unsafeBody: by default read into a String
631-
println(response.unsafeBody)
627+
println(response.body)
632628
```
633629
```scala
634630
// Dispatch

0 commit comments

Comments
 (0)