Skip to content

Commit

Permalink
fix(node_helper): display array instead of first object
Browse files Browse the repository at this point in the history
fixes #4
BREAKING CHANGE
  • Loading branch information
DanielHabenicht committed Mar 3, 2021
1 parent 3813789 commit fdc00b3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ module.exports = NodeHelper.create({
payload.config.values == undefined ||
payload.config.values.length == 0
) {
// Values are not defined fetch first properties
var firstObject = jsonData;
if (Array.isArray(jsonData)) {
firstObject = jsonData[0];
}
// Values are not defined return whole object properties
responseObject = {
identifier: payload.identifier,
data: Object.keys(firstObject).map((prop) => {
return { title: prop, value: firstObject[prop] };
data: Object.keys(jsonData).map((prop) => {
return { title: prop, value: jsonData[prop] };
})
};
} else {
Expand Down

0 comments on commit fdc00b3

Please sign in to comment.