From c1217463809e366ec597d79e4c9d36040d6db945 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Thu, 11 Apr 2019 19:31:31 +0200 Subject: [PATCH] Fixed bug on search --- middleware/Vegetables.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/middleware/Vegetables.js b/middleware/Vegetables.js index 830c968..f33d98d 100644 --- a/middleware/Vegetables.js +++ b/middleware/Vegetables.js @@ -181,17 +181,18 @@ class Vegetables { const item = items.rows[j].toJSON() let k = 0 for (k = 0; k < vegetables.length; k += 1) { - if (item[j].name.localeCompare(vegetables[k].name) === -1) { + if (item.name.localeCompare(vegetables[k].name) === -1) { break } } - vegetables.splice(k, 0, item[j]) + vegetables.splice(k, 0, item) } callback(null, { count: vegetables.length, rows: vegetables }) }) .catch((e) => { + console.log('ERR:', e) callback(e, null) }) }