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) .map(encodeURIComponent)
.join("&"); .join("&");
const inner = Object.entries(data).map(([k, v]) => [ const inner = Object.entries(data)
k, .filter(([_, v]) => typeof v !== "undefined")
nestedUrlSearchParams(v, false), .map(([k, v]) => [k, nestedUrlSearchParams(v, false)]);
]);
return new URLSearchParams(inner).toString(); return new URLSearchParams(inner).toString();