https://kotlinlang.org logo
#ktor
Title
# ktor
j

james

03/05/2024, 10:41 PM
are there any “gotchas” around handling Ktor client responses for the
js
target? I have a Ktor client which is communicating with my API successfully, converting the response body into a
String
, and it works as expected on all JVM and native targets, but I’ve just added a
js
target and while I can see the successful fetch response in Chrome dev tools, if I print the response to the console it is always blank this is the first time I’ve setup my own
js
target in a project, so I wonder if I’ve missed something? content negotiation with json serialization is installed, but I wouldn’t have expected that to make a difference here since I’m just trying to receive the body as a
String
and not another serializable object
a

Aleksei Tirman [JB]

03/06/2024, 7:42 AM
This functionality should work the same way on the JS target. Can you share a code snippet or your project to troubleshoot the issue?
j

james

03/06/2024, 8:01 AM
Thanks Aleksei! On my commute home right now and was about to post that I figured it out. It was a dependency configuration issue, and I'll leave the explanation of my mistake here so future explorers can find it if they search for a similar problem. My mistake was mixing experimental Ktor WASM dependencies with my standard ones. I didn't realise I still had a dependency resolution override which forced a dependency to grab the
3.0.0-wasm2
version from the JetBrains experimental maven repo. Somehow it was silently incompatible with one of the others, so there was no visible error or exception 😬