Skip to content

Commit

Permalink
fix: error in categories endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sooluh committed Aug 13, 2023
1 parent 6f337ad commit 04b346a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/controllers/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04b346a

Please sign in to comment.