From 04eed3d0b23a1c1e7887ec0168cb3b02807a2a58 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 10 May 2020 00:35:35 +0200 Subject: Fix RestClient data serialization. --- src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt b/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt index 9011c780..f7091f96 100644 --- a/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt +++ b/src/main/kotlin/pl/treksoft/kvision/rest/RestClient.kt @@ -31,7 +31,7 @@ import pl.treksoft.jquery.JQueryAjaxSettings import pl.treksoft.jquery.JQueryXHR import pl.treksoft.jquery.jQuery import pl.treksoft.kvision.types.DateSerializer -import pl.treksoft.kvision.utils.JSON.toObj +import pl.treksoft.kvision.utils.JSON import pl.treksoft.kvision.utils.obj import kotlin.js.Date import kotlin.js.Promise @@ -131,7 +131,7 @@ open class RestClient { contentType: String = "application/json", beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null ): Promise { - return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend) + return remoteCall(url, JSON.plain.stringify(serializer, data), method, contentType, beforeSend) } @@ -157,7 +157,13 @@ open class RestClient { beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null, transform: ((dynamic) -> dynamic)? = null ): Promise { - return remoteCall(url, data.toObj(serializer), method, contentType, beforeSend).then { result: dynamic -> + return remoteCall( + url, + JSON.plain.stringify(serializer, data), + method, + contentType, + beforeSend + ).then { result: dynamic -> val transformed = if (transform != null) { transform(result) } else { @@ -413,7 +419,7 @@ open class RestClient { contentType: String = "application/json", beforeSend: ((JQueryXHR, JQueryAjaxSettings) -> Boolean)? = null ): Promise> { - return remoteRequest(url, data.toObj(serializer), method, contentType, beforeSend) + return remoteRequest(url, JSON.plain.stringify(serializer, data), method, contentType, beforeSend) } @@ -441,7 +447,7 @@ open class RestClient { ): Promise> { return remoteRequest( url, - data.toObj(serializer), + JSON.plain.stringify(serializer, data), method, contentType, beforeSend -- cgit