mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
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 <vhansson@opennebula.io> (cherry picked from commit 51ef95d720b996f5629e749ff17e9b8307cd18fe)
This commit is contained in:
parent
1f003cbcd5
commit
c4746824d8
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user