Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The request cannot be sent with the parameter ReqeustInit. #70

Open
QingMingKt opened this issue Sep 24, 2024 · 0 comments
Open

The request cannot be sent with the parameter ReqeustInit. #70

QingMingKt opened this issue Sep 24, 2024 · 0 comments

Comments

@QingMingKt
Copy link

When sending a request using window.fetch, if you use ReqeustInit, you will not be able to send the request, even if RequestInit does not write anything.

(Because the picture cannot be uploaded, post the code.)

object ApiUtil {
    suspend fun login(username: String, password: String): ResultUDM<JsString> {
        val response = window.fetch(
            "http://127.0.0.1:9002/user/login", RequestInit(
                method = "POST", body = LoginUser(username, password)
            )
        ).await<Response>()
        return response.json().await()
    }
}

Browser console error:JsException: Exception was thrown while running JavaScript code

If the ReqeustInit parameter is removed, it can run normally.

Version information:

[versions]
androidx-lifecycle = "2.8.0"
compose-plugin = "1.6.11"
junit = "4.13.2"
kotlin = "2.0.20"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }

[plugins]
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant