diff --git a/src/routes/getLockCategories.ts b/src/routes/getLockCategories.ts index 7267b86..d7707f9 100644 --- a/src/routes/getLockCategories.ts +++ b/src/routes/getLockCategories.ts @@ -14,16 +14,14 @@ export async function getLockCategories(req: Request, res: Response): Promise item.category); if (categories.length === 0 || !categories[0]) return res.sendStatus(404); - // Get existing lock categories markers - const reasons = row.map(item => item.reason); - let longReason = ""; - // set longReason if current length is longer - reasons.forEach((e) => { if (e.length > longReason.length) longReason = e; }); + // Get longest lock reason + const reason = row.map(item => item.reason) + .reduce((a,b) => (a.length > b.length) ? a : b); return res.send({ - reason: longReason, + reason, categories }); } catch (err) {