New design, added category & bug fixes

This commit is contained in:
pheralb
2022-01-21 22:30:32 +00:00
parent 2706236410
commit 57f2339589
43 changed files with 1916 additions and 191 deletions
+10 -1
View File
@@ -1,7 +1,7 @@
import db from "data/icons";
export default function handler(req, res) {
const { id, q } = req.query;
const { id, q, c } = req.query;
// 🔎 Search by id (ex: ?id=1) ->
if (id) {
@@ -18,6 +18,15 @@ export default function handler(req, res) {
return res.status(200).json(results);
}
// 🔎 Search by category (ex: ?c=library) ->
if (c) {
const results = db.filter((product) => {
const { category } = product;
return category.toLowerCase().includes(c.toLowerCase());
});
return res.status(200).json(results);
}
// ✖ Error ->
res.status(400).json({ info: 'Error: api query not found.' });
}