Skip to content

Commit 7665ebe

Browse files
committed
Fix all the problems with the newer library versions
1 parent cbfc14d commit 7665ebe

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ kotlin {
3232
sourceSets {
3333
val commonMain by getting {
3434
dependencies {
35-
implementation(libs.ktor.client.core)
3635
implementation(libs.ktor.serialization.json)
3736
implementation(libs.kotlinx.serialization.json)
3837
}
@@ -59,8 +58,7 @@ kotlin {
5958

6059
val jsMain by getting {
6160
dependencies {
62-
implementation(libs.ktor.client.contentNegotiation)
63-
// implementation("io.ktor:ktor-client-js:$ktorVersion")
61+
implementation(libs.ktor.client.core)
6462
implementation(kotlinWrappers.react)
6563
implementation(kotlinWrappers.reactDom)
6664
implementation(libs.ktor.client.contentNegotiation)

src/commonMain/kotlin/ShoppingListItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ data class ShoppingListItem(val desc: String, val priority: Int) {
55
val id: Int = desc.hashCode()
66

77
companion object {
8-
const val path = "/shoppingList"
8+
const val PATH = "/shoppingList"
99
}
1010
}

src/jsMain/kotlin/Api.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@ import io.ktor.client.plugins.contentnegotiation.*
55
import io.ktor.client.request.*
66
import io.ktor.serialization.kotlinx.json.*
77

8-
import kotlinx.browser.window
9-
10-
val jsonClient = HttpClient {
8+
val client = HttpClient {
119
install(ContentNegotiation) {
1210
json()
1311
}
1412
}
1513

1614
suspend fun getShoppingList(): List<ShoppingListItem> {
17-
return jsonClient.get(ShoppingListItem.path).body()
15+
return client.get(ShoppingListItem.PATH).body()
1816
}
1917

2018
suspend fun addShoppingListItem(shoppingListItem: ShoppingListItem) {
21-
jsonClient.post(ShoppingListItem.path) {
19+
client.post(ShoppingListItem.PATH) {
2220
contentType(ContentType.Application.Json)
2321
setBody(shoppingListItem)
2422
}
2523
}
2624

2725
suspend fun deleteShoppingListItem(shoppingListItem: ShoppingListItem) {
28-
jsonClient.delete(ShoppingListItem.path + "/${shoppingListItem.id}")
26+
client.delete(ShoppingListItem.PATH + "/${shoppingListItem.id}")
2927
}

src/jsMain/kotlin/Main.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import web.dom.document
22
import react.create
33
import react.dom.client.createRoot
4+
import web.dom.ElementId
45

56
fun main() {
6-
val container = document.getElementById("root") ?: error("Couldn't find container!")
7+
val rootId = ElementId("root")
8+
val container = document.getElementById(rootId) ?: error("Couldn't find container!")
79
createRoot(container).render(App.create())
810
}

src/jvmMain/kotlin/Server.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun main() {
4242

4343
routing {
4444
staticResources("/", "static")
45-
route(ShoppingListItem.path) {
45+
route(ShoppingListItem.PATH) {
4646
get {
4747
call.respond(collection.find().toList())
4848
}

0 commit comments

Comments
 (0)