Merge pull request #867 from Safelite/defect/digital/SSR-1632

SSR-1632 Don't pass null values
This commit is contained in:
Josh Dassinger 2024-10-16 13:43:19 -05:00 committed by GitHub
commit a1fb19b37c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,11 +47,16 @@ export function getTaxLineItemQueryString(lineItems, parameterName) {
export function buildURLSearchParams(data) {
const params = new URLSearchParams();
Object.entries(data).forEach(([key, value]) => {
if (value == null) {
return;
}
if (Array.isArray(value)) {
value.forEach((arrayValue, index) => {
if (typeof value === 'object') {
Object.entries(arrayValue).forEach(([objectKey, objectValue]) => {
params.append(`${key}[${index}].${objectKey}`, `${objectValue}`);
if (objectValue != null) {
params.append(`${key}[${index}].${objectKey}`, `${objectValue}`);
}
});
} else {
params.append(`${key}[${index}]`, `${value}`);