From ebde45eda4175a32cab807afd3da67559f5ccd83 Mon Sep 17 00:00:00 2001 From: lcflight Date: Thu, 29 Feb 2024 10:29:24 -0500 Subject: [PATCH] stringifys filters --- src/interceptors.spec.ts | 10 ++++++++++ src/interceptors.ts | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/interceptors.spec.ts b/src/interceptors.spec.ts index 5f8f606..34c2fcb 100644 --- a/src/interceptors.spec.ts +++ b/src/interceptors.spec.ts @@ -37,4 +37,14 @@ describe("Request Interceptor", () => { await Promise.all(promises); }); + + it("stringifys the filters", async () => { + const config = await interceptors.onRequest({ + params: { filters: { id: 1 } }, + } as any); + + expect(config.params).toEqual( + expect.objectContaining({ filters: '{"id":1}' }), + ); + }); }); diff --git a/src/interceptors.ts b/src/interceptors.ts index eaf3183..bdbda4e 100644 --- a/src/interceptors.ts +++ b/src/interceptors.ts @@ -18,6 +18,12 @@ export class Interceptors { ...(config.params as Record), }; + const params = config.params as { filters?: unknown }; + + if (params.filters !== undefined) { + params.filters = JSON.stringify(params.filters); + } + return new Promise((resolve) => { const interval = setInterval(() => { if (this.pending < MAX_REQUESTS_COUNT) {