Drop map values that are undefined from API requests

This commit is contained in:
Natty 2024-01-16 18:09:28 +01:00
parent 94cff7c2c8
commit 98fb2ef0d8
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 3 additions and 4 deletions

View File

@ -36,10 +36,9 @@ function nestedUrlSearchParams(data: any, topLevel: boolean = true): string {
.map(encodeURIComponent)
.join("&");
const inner = Object.entries(data).map(([k, v]) => [
k,
nestedUrlSearchParams(v, false),
]);
const inner = Object.entries(data)
.filter(([_, v]) => typeof v !== "undefined")
.map(([k, v]) => [k, nestedUrlSearchParams(v, false)]);
return new URLSearchParams(inner).toString();