diff --git a/middleware/Vegetables.js b/middleware/Vegetables.js index 20b0c71..830c968 100644 --- a/middleware/Vegetables.js +++ b/middleware/Vegetables.js @@ -175,18 +175,18 @@ class Vegetables { return false } - const _items = items.rows.toJSON() let vegetables = [] - for (let j = 0; j < _items.length; j += 1) { + for (let j = 0; j < items.rows.length; j += 1) { + const item = items.rows[j].toJSON() let k = 0 for (k = 0; k < vegetables.length; k += 1) { - if (_items[j].name.localeCompare(vegetables[k].name) === -1) { + if (item[j].name.localeCompare(vegetables[k].name) === -1) { break } } - vegetables.splice(k, 0, _items[j]) + vegetables.splice(k, 0, item[j]) } callback(null, { count: vegetables.length, rows: vegetables })