File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -7,25 +7,23 @@ import io.ktor.serialization.kotlinx.json.*
7
7
8
8
import kotlinx.browser.window
9
9
10
- val endpoint = window.location.origin // only needed until https://github.com/ktorio/ktor/issues/1695 is resolved
11
-
12
10
val jsonClient = HttpClient {
13
11
install(ContentNegotiation ) {
14
12
json()
15
13
}
16
14
}
17
15
18
16
suspend fun getShoppingList (): List <ShoppingListItem > {
19
- return jsonClient.get(endpoint + ShoppingListItem .path).body()
17
+ return jsonClient.get(ShoppingListItem .path).body()
20
18
}
21
19
22
20
suspend fun addShoppingListItem (shoppingListItem : ShoppingListItem ) {
23
- jsonClient.post(endpoint + ShoppingListItem .path) {
21
+ jsonClient.post(ShoppingListItem .path) {
24
22
contentType(ContentType .Application .Json )
25
23
setBody(shoppingListItem)
26
- }
24
+ }
27
25
}
28
26
29
27
suspend fun deleteShoppingListItem (shoppingListItem : ShoppingListItem ) {
30
- jsonClient.delete(endpoint + ShoppingListItem .path + " /${shoppingListItem.id} " )
31
- }
28
+ jsonClient.delete(ShoppingListItem .path + " /${shoppingListItem.id} " )
29
+ }
You can’t perform that action at this time.
0 commit comments