From 109bb259cbc064e884979736888f62917f9b3bca Mon Sep 17 00:00:00 2001 From: Bo Simonsen Date: Tue, 2 Jul 2019 14:00:21 +0200 Subject: [PATCH] fix date serialization for restful calls The serialization for restful query string is quite primitive (but sufficient), if string we just pass it through, otherwise we use JSON serialization. However, for Date this does not work out, which this commit fixes. --- src/restful.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/restful.ts b/src/restful.ts index 28f7231..bb83c96 100644 --- a/src/restful.ts +++ b/src/restful.ts @@ -18,7 +18,9 @@ export function mk_query(params: Object) : string { qs += '&' if( value != null ) { - if( typeof value != 'string' ) + if( value instanceof Date) + value = value.toISOString() + else if( typeof value != 'string' ) value = JSON.stringify( value ) qs += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`