aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft')
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt11
1 files changed, 3 insertions, 8 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
index 1ec5610a..e15e43cb 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
@@ -25,18 +25,15 @@ import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.DynamicObjectParser
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.SerializationStrategy
-import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer
import kotlinx.serialization.stringify
import pl.treksoft.jquery.JQueryAjaxSettings
import pl.treksoft.jquery.JQueryXHR
import pl.treksoft.jquery.jQuery
import pl.treksoft.kvision.utils.JSON
+import pl.treksoft.kvision.utils.JSON.toObj
import pl.treksoft.kvision.utils.obj
import kotlin.js.Promise
-import kotlin.js.then
-import kotlin.js.undefined
-import kotlin.js.JSON as NativeJSON
/**
* HTTP status unauthorized (401).
@@ -193,8 +190,7 @@ open class CallAgent {
contentType: String = "application/json",
beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null
): Promise<dynamic> {
- val dynamicData = NativeJSON.parse<dynamic>(Json.stringify(serializer, data))
- return remoteCall(url, dynamicData, method, contentType, beforeSend)
+ return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend)
}
@@ -220,8 +216,7 @@ open class CallAgent {
beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null,
transform: ((dynamic) -> dynamic)? = null
): Promise<T> {
- val dynamicData = NativeJSON.parse<dynamic>(Json.stringify(serializer, data))
- return remoteCall(url, dynamicData, method, contentType, beforeSend).then { result: dynamic ->
+ return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend).then { result: dynamic ->
val transformed = if (transform != null) {
transform(result)
} else {