Hey ,
I saw this in the documentation
Notice the format in which we return the results of the calculation:
let items = $input.all();
let totalBooked = items.length;
let bookedSum = 0;
for (let i=0; i < items.length; i++) {
bookedSum = bookedSum + items[i].json.orderPrice;
}
return [{ json: {totalBooked, bookedSum} }];
Data structure error
If you don’t use the correct data structure, you will get an error message: Error: Always an Array of items has to be returned!
But when I make this it works why ?
return {totalBooked, bookedSum} ;
My complete code :
let items = $input.all();let totalBooked = items.length;let bookedSum = 0;
for (let i=0; i < items.length; i++) {bookedSum = bookedSum + items[i].json.orderPrice;}
return {totalBooked, bookedSum} ;

