Last active
May 24, 2019 06:05
-
-
Save Syex/3c9314afd90e8e5fd6b59ba19cdaca40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val client = HttpClient(clientEngine) { | |
install(JsonFeature) { | |
serializer = KotlinxSerializer() | |
} | |
} | |
suspend fun getPopularMovies(): PopularMoviesEntity { | |
val response = client.get<HttpResponse> { | |
url { | |
protocol = URLProtocol.HTTPS | |
host = "api.themoviedb.org/4" | |
encodedPath = "/discover/movie" | |
parameter("sort_by", "popularity.desc") | |
header("Authorization", "Bearer $yourApiKey") | |
} | |
} | |
val jsonBody = response.readText() | |
return Json.parse(PopularMoviesEntity.serializer(), jsonBody) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment