JS - $this$ is undefined
- Dominant language
- Kotlin
- Stars
- 14.5k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 49
Description
Hi,
I'm trying out ktor with coroutines in a multiplatform project. I'm building for Android, iOS and Javascript.
For the moment my code consists of a simple get call of an api. It works fine on Android and iOS, but I'm getting an `$this$ is undefined` when my javascript calls the same code.
My gradle dependencies:
```
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.14.0")
implementation("io.ktor:ktor-client-js:1.3.1")
implementation("io.ktor:ktor-client-core-js:1.3.1")
implementation("io.ktor:ktor-client-json:1.3.1")
implementation("io.ktor:ktor-client-serialization-js:1.3.1")
```
Here are the multiplaform JS variations:
```import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.Dispatchers
actual val uiDispatcher: CoroutineContext
get() = Dispatchers.Main
actual val defaultDispatcher: CoroutineContext
get() = Dispatchers.Default
```
```import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.js.Js
actual object PlatformServiceLocator {
actual val httpClientEngine: HttpClientEngine by lazy { Js.create() }
}
```
Thanks for the help
Contributor guide
Assessment
This issue has not been assessed yet.