Skip to content

Instantly share code, notes, and snippets.

@nunomazer
Last active July 14, 2021 00:46
Show Gist options
  • Save nunomazer/0b9b308a78e14148d8710d37ab7c82e9 to your computer and use it in GitHub Desktop.
Save nunomazer/0b9b308a78e14148d8710d37ab7c82e9 to your computer and use it in GitHub Desktop.
Exemplo de uso de khttp com Kotlin
Tutorial para a seção do livro de dev mobile
khttp.get("https://meuservidor.com.br/api/usuarios")
khttp.get(
url = "https://meuservidor.com.br/produtos",
params = mapOf("categoria" to "Carnes"))
<dependency>
<groupId>khttp</groupId>
<artifactId>khttp</artifactId>
<version>0.1.0</version>
</dependency>
val resposta : Response = khttp.get(
url = "https://meuservidor.com.br/produtos",
params = mapOf("categoria" to "Carnes"))
val objeto : JSONObject = resposta.jsonObject
print(objeto["mensagem"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment