From b0824a7d90f20a2e1d22129091bd62cf6567e722 Mon Sep 17 00:00:00 2001 From: Mikko Saarinen Date: Wed, 4 Oct 2023 09:30:49 +0300 Subject: [PATCH] Remove null settings from fetch --- src/views/ServiceTreeView/ServiceTreeView.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/ServiceTreeView/ServiceTreeView.js b/src/views/ServiceTreeView/ServiceTreeView.js index 5b5854e0b..f4dd75b0f 100644 --- a/src/views/ServiceTreeView/ServiceTreeView.js +++ b/src/views/ServiceTreeView/ServiceTreeView.js @@ -95,9 +95,12 @@ const ServiceTreeView = ({ intl, variant }) => { // Do not fetch unit counts again for nodes that have the data, unless specified by fullSearch const filteredIdList = fullSearch ? idList : idList.filter(id => !unitCounts.some(count => count.id === id)) const smAPI = new ServiceMapAPI(); - const fetchOptions = { - organization: organizationSettings.map(setting => setting.id), - municipality: citySettings, + const fetchOptions = {}; + if (organizationSettings.length) { + fetchOptions.organization = organizationSettings.map(setting => setting.id); + } + if (citySettings.length) { + fetchOptions.municipality = citySettings; } const counts = await Promise.all( filteredIdList.map(async (id) => {