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

Antoni Zwolski

02/21/2024, 5:38 PM
What can cause the problem? I have followed this instruction: https://ktor.io/docs/client-dependencies.html#plugin-dependency
Copy code
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
}

kotlin {
    @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
       browser()
    }


    
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    
    jvm()
    
    sourceSets {
        commonMain.dependencies {
            implementation(libs.ktor.client.core)
            implementation(libs.ktor.client.okhttp)
        }
    }
}

android {
    namespace = "org.freshood.app.shared"
    compileSdk = libs.versions.android.compileSdk.get().toInt()
    defaultConfig {
        minSdk = libs.versions.android.minSdk.get().toInt()
    }
}
a

AdamW

02/21/2024, 6:00 PM
https://ktor.io/docs/http-client-engines.html#platforms the OkHttp engine only supports JVM/Android
a

Antoni Zwolski

02/21/2024, 6:03 PM
Will native engine work with wasmJS?
a

AdamW

02/21/2024, 6:08 PM
WasmJS support is coming with Ktor 3.0 IIRC.
a

Antoni Zwolski

02/21/2024, 6:19 PM
how i am supposed to do the http request on wasm? is it even possible?
e

ephemient

02/21/2024, 7:02 PM
wasmJs has no http capability on its own. until other wrappers exist, you can bridge to JS's fetch API
wasmWasi will require a different path, possibly https://github.com/WebAssembly/wasi-http
3 Views