From ddd0ba2bef801dbd299ba59b1cfa223a40ba9dd7 Mon Sep 17 00:00:00 2001 From: Antonio Pescione Date: Thu, 17 Oct 2024 15:47:37 +0200 Subject: [PATCH 1/2] serilize Date to toISOString in query params --- src/treaty2/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index ddb0768..fe1a5be 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -196,6 +196,11 @@ const createProxy = ( continue } + if(value instanceof Date) { + append(key, value.toISOString()) + continue + } + if (typeof value === 'object') { append(key, JSON.stringify(value)) continue From c41b2d7aedd3b3a51ab18246b73d1f2dbd382516 Mon Sep 17 00:00:00 2001 From: Antonio Pescione Date: Fri, 18 Oct 2024 10:11:31 +0200 Subject: [PATCH 2/2] check even it is a valid Date to avoid error in toISOString --- src/treaty2/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index fe1a5be..b89875b 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -196,7 +196,7 @@ const createProxy = ( continue } - if(value instanceof Date) { + if(value instanceof Date && !isNaN(value.getTime())) { append(key, value.toISOString()) continue }