Skip to content

Commit

Permalink
fix: server-client no longer sends undefined query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Oct 17, 2024
1 parent 324beaf commit 7d7fc08
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/server-client/__tests__/__dataSets__/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,32 @@ export default [
statusText: 'OK',
},
},
{
label: 'make get request with query params and remove undefined',
request: ['/my/path?foo=bar', 'GET'],
response: [
200,
{
fizz: 'buzz',
},
],
clientMethod: 'sendGetRequest',
parameters: [
`${BASE_URL}/my/path`,
{
foo: 'bar',
fizz: undefined,
},
],
expected: {
config: expect.anything(),
data: {
fizz: 'buzz',
},
headers: expect.anything(),
request: expect.anything(),
status: 200,
statusText: 'OK',
},
},
];
4 changes: 4 additions & 0 deletions packages/server-client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ export class Client {
request = await this.addAuthenticationToRequest(request);

log('Request prepared', request);
if (request.params) {
request.params = JSON.parse(JSON.stringify(request.params));
}

const url = new URL(request.url as string);
const params = new URLSearchParams(request.params);

Expand Down

0 comments on commit 7d7fc08

Please sign in to comment.