From 51ef95d720b996f5629e749ff17e9b8307cd18fe Mon Sep 17 00:00:00 2001 From: vichansson Date: Fri, 18 Oct 2024 15:42:54 +0300 Subject: [PATCH] M #-: Fix apiResponse data handling (#3268) - If the API response returns only 1 object, it won't be array wrapped, causing issues when formatting the response to a dataset. Now transformApiResponseToDataset always casts the response to an array. Signed-off-by: Victor Hansson --- .../Charts/MultiChart/helpers/scripts/dataProcessing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/dataProcessing.js b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/dataProcessing.js index 4def895293..b87becbfec 100644 --- a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/dataProcessing.js +++ b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/dataProcessing.js @@ -114,12 +114,13 @@ export const transformApiResponseToDataset = ( depth = 0, dataArrayPath ) => { - const dataArray = + const dataArray = _.castArray( (_.isEmpty(apiResponse) ? [] : dataArrayPath ? _.get(apiResponse, dataArrayPath) : findFirstArray(apiResponse, depth)) ?? [] + ) const flattenObject = (obj, prefix = '') => Object.keys(obj).reduce((acc, k) => {