svgl/pages/api/categories.js
2022-01-21 22:30:32 +00:00

14 lines
360 B
JavaScript

import db from "data/icons";
// 📦 Show categories ->
export default function handler(req, res) {
try {
const categories = db
.map((item) => item.category)
.filter((category, index, self) => self.indexOf(category) === index);
return res.status(200).json(categories);
} catch (err) {
res.status(400).json({ message: err });
}
}