From 04b346ae1c0cc18ec402ec3370fcfdbe691ec84d Mon Sep 17 00:00:00 2001 From: Abu Masyail <20874779+sooluh@users.noreply.github.com> Date: Sun, 13 Aug 2023 08:28:13 +0700 Subject: [PATCH] fix: error in categories endpoint --- src/controllers/categories.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controllers/categories.ts b/src/controllers/categories.ts index dffee7b..6f5a6d7 100644 --- a/src/controllers/categories.ts +++ b/src/controllers/categories.ts @@ -6,6 +6,10 @@ export const categories = (app: FastifyInstance) => { return (request: FastifyRequest, reply: FastifyReply) => { const language = request.headers['accept-language'] || 'id' + if (!(language in app.data.categories)) { + return sendNotFound(reply) + } + const result = app.data.categories[language].map( (category: CategoryType & { total?: number }) => { const total = app.data.items[category.slug][language].length