Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Commit

Permalink
Fixed endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tahirmurata committed Sep 18, 2024
1 parent 1c522ad commit 87cc933
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,14 @@ func (s *Server) NodeFoodCountHandler(c echo.Context) error {
return echo.ErrBadRequest
}

result := make(map[string]int)
for _, food := range foodCount {
result[food.Name] = food.Count
foodsArray := make([]map[string]interface{}, len(foodCount))
for i, food := range foodCount {
foodsArray[i] = map[string]interface{}{
"id": food.ID,
"name": food.Name,
"count": food.Count,
}
}

return c.JSON(http.StatusOK, result)
return c.JSON(http.StatusOK, foodsArray)
}

0 comments on commit 87cc933

Please sign in to comment.