Hello, is Ktor client supported on WasmJS? I'm get...
# multiplatform
i
Hello, is Ktor client supported on WasmJS? I'm getting errors on Gradle sync:
Copy code
:shared:wasmJsMain: Could not resolve io.ktor:ktor-client-content-negotiation:2.3.10
If not are there any known workarounds? I want our
commonMain
Compose app to be able to run in the browser. I have the following abstraction that seems to work on the other platforms:
Copy code
class JVMPlatform: Platform {
    override val name: String = "Java ${System.getProperty("java.version")}"

    override fun log(level: LogLevel, msg: String) {
        println("${level.name}: $msg")
    }

    override fun httpClient(
        config: HttpClientConfig<*>.() -> Unit
    ): HttpClient = HttpClient(Java) {
        config(this)
    }
}
2
j
you need to use
io.ktor:ktor-client-core:3.0.0-wasm2
etc for now
thank you color 1
and
<https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental>
repo
thank you color 1
i
Awesome. Thank you! Would it work for the other platforms/target? I'll give it a shot! Much appreciated. I have:
Copy code
ktor-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
So I'll just change the
ktor
version to "3.0.0-wasm2"
j
yeah, that should work....example of it's use in following https://github.com/joreilly/ClimateTraceKMP
K 2
i
Worked for me! Amazing
👍 1
n
@John O'Reilly @Iliyan Germanov Is there a way to easily expose compose methods to JS? I have a project with both
composeApp
and
shared
- more than likely looking mostly to ship shared logic to web. I was having a lot of trouble doing this in compose but found exporting the JS from
shared
was very simple BUT falls apart when trying to use KTOR with WASM. Any tips here? Thank you!
626 Views