Drop map values that are undefined from API requests
This commit is contained in:
parent
94cff7c2c8
commit
98fb2ef0d8
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue