Darren Bell

06/17/2019, 11:23 PM
On the javascript side I am getting a similar error to someone earlier when using the HttpClient getting
List is empty.", cause_th0jdv$_0: null, name: "NoSuchElementException"
My gradle file has the following
compile ("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${LibraryVersions.kotlin_js_serialization_version}")
    compile ("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${LibraryVersions.kotlin_js_serialization_version}")
    compile ("io.ktor:ktor-client-core:${LibraryVersions.ktor_version}")
    compile ("io.ktor:ktor-client-js:${LibraryVersions.ktor_version}")
    compile ("io.ktor:ktor-client-json-js:${LibraryVersions.ktor_version}")
    compile ("io.ktor:ktor-client-serialization-js:${LibraryVersions.ktor_version}")
    compile ("io.ktor:ktor-client-auth-basic-js:${LibraryVersions.ktor_version}")
Has anyone managed to get this working?


06/18/2019, 7:39 AM
Hi @Darren Bell, probably you need to add one of client engines in dependencies:

Darren Bell

06/18/2019, 8:49 AM
@e5l Thanks for replying. So I have the following
val client = HttpClient(Js).config {
            followRedirects = false
But I'm still getting the issue that there appears to be no defaultSerializer. Is my configuration incorrect? I'm using version 1.2.1 of ktor, and I'm pretty certain I had this working in a previous version.
👀 1
Also, of note. When I remove the
, deserialization appears to work as expected. But when I need to serialize an object for a POST, then I get a class cast exception instead. Cheers
After a bit more searching I found the answer:
val client = HttpClient(Js).config {
        install(JsonFeature) {
            this.serializer = KotlinxSerializer(Json.nonstrict)
Simple when you know how!