mirror of
https://github.com/pheralb/svgl.git
synced 2025-02-11 09:40:31 +08:00
⚒️ Add .json to the import.
This commit is contained in:
parent
f2cfedcbb0
commit
efd2fbbe26
@ -1,4 +1,4 @@
|
|||||||
import db from "data/svgs";
|
import db from "data/svgs.json";
|
||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
import { SvgData } from "@/interfaces/svgData";
|
import { SvgData } from "@/interfaces/svgData";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
import db from "data/svgs";
|
import db from "data/svgs.json";
|
||||||
|
|
||||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
// Get unique categories:
|
// Get unique categories:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import db from "data/svgs";
|
import db from "data/svgs.json";
|
||||||
import { NextApiRequest, NextApiResponse } from "next";
|
import { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
@ -14,7 +14,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (q) {
|
if (q) {
|
||||||
const results = db.filter((product) => {
|
const results = db.filter((product) => {
|
||||||
const { title } = product;
|
const { title } = product;
|
||||||
return title;
|
return title.toLowerCase().includes(q.toString());
|
||||||
});
|
});
|
||||||
return res.status(200).json(results);
|
return res.status(200).json(results);
|
||||||
}
|
}
|
||||||
@ -23,11 +23,11 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (c) {
|
if (c) {
|
||||||
const results = db.filter((product) => {
|
const results = db.filter((product) => {
|
||||||
const { category } = product;
|
const { category } = product;
|
||||||
return category;
|
return category.toLowerCase().includes(q.toString());
|
||||||
});
|
});
|
||||||
return res.status(200).json(results);
|
return res.status(200).json(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✖ Error ->
|
// ✖ Error ->
|
||||||
res.status(400).json({ info: "Error: api query not found." });
|
res.status(400).json({ info: "[/api/search] Error: api query not found." });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user