UNuX
08/29/2021, 11:27 AMAppScope.launch {
DataAccess.getRecords().catch {
Toast.error("Błąd pobierania danych z serwera")
}.then { records ->
println("Records: $records")
val filtered = ArrayList<EntryRecord>()
for(record in records.unsafeCast<List<EntryRecord>>()) {
if(!record.pricePrepaidConfirmed || !record.priceTotalConfirmed) {
filtered.add(record)
}
}
records variable is of type kotlin.Unit apparently...Robert Jaros
08/29/2021, 11:33 AMgetRecords()
defined?UNuX
08/29/2021, 11:36 AMfun getRecords(): Promise<List<EntryRecord>> {
return RestClient().call("/api/v1/records")
}
Robert Jaros
08/29/2021, 11:46 AMfun getRecords(): Promise<List<EntryRecord>> {
return RestClient().call("/api/v1/records") {
deserializer = ListSerializer(EntryRecord.serializer())
}
}
UNuX
08/29/2021, 11:56 AMRobert Jaros
08/29/2021, 12:03 PMUNuX
08/29/2021, 12:04 PMUNuX
08/29/2021, 12:04 PM[{"id":1,"creationDate":null,"contractType":"Test","contractNumber":"Test","pricePrepaid":20099,"pricePrepaidConfirmed":false,"priceTotal":400099,"priceTotalConfirmed":false,"additionalInformation":""}]
UNuX
08/29/2021, 12:05 PMRobert Jaros
08/29/2021, 12:26 PMRobert Jaros
08/29/2021, 12:30 PMRestClient
from KVision 5 doesn't include serialization module for Date
type. So you will need to provide a serializer if you want to use Date
.
E.g.:
fun getRecords(): Promise<List<EntryRecord>> {
return RestClient{
serializersModule = serializersModuleOf(DateSerializer)
}.call("/test.json") {
deserializer = ListSerializer(EntryRecord.serializer())
}
}
Robert Jaros
08/29/2021, 12:41 PMUNuX
08/30/2021, 12:00 AMAnd what do you mean by "specific piping for handling reponses from server-side APIs"?A long time ago when I was trying to learn js I remember that a few frameworks had some helper methods to fetch data from the backend, I suspected that kvision might have something like this as well
UNuX
08/30/2021, 12:08 AMIt seems to work for me but you have got a typo "additionaInformation" instead of "additionalInfo".Eh, where? Full project search for the phrase returns only additionalInformation in my project. Also I setill have the same problem...
UNuX
08/30/2021, 12:25 AM