Hi everyone! I want to make a simple http request ...
# multiplatform
a
Hi everyone! I want to make a simple http request with Ktor and display the result in a dropdown. I know on Android/iOS/desktop
runBlocking
works, but it doesn’t on work on web. I tries to use
Copy code
expect fun httpClient() ...
    ...
    val scope = rememberCoroutineScope()
    val someVal = remember { mutableStateOf(listOf<ValueView>()) }
    OutlinedTextField(
        value = someVal,
        onValueChange = {
            someVal = someVal
            scope.launch {
                val values = <http://httpClient.post|httpClient.post> { ... }
                log.i("Values") { values }
                someVal.value = values.first()
            }
        },
        label = { Text("Val") },
    )
But it seems it doesn’t make a request at all. I can not call
.await
because it is
suspended
. Any ideas, please??
c
launch it in a global scope just to see what happens