You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
657 B
22 lines
657 B
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
import { OkPacket, QueryError, RowDataPacket } from "mysql2";
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import { pool } from "../../server/db/connect";
|
|
|
|
type Data = {
|
|
row: string,
|
|
}
|
|
|
|
const queryString = "SELECT id,title,description FROM products WHERE type='pizza' and status=1";
|
|
|
|
export default function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse<Data>)
|
|
{
|
|
pool.query(
|
|
queryString,
|
|
(err: QueryError, rows: RowDataPacket[0]) => {
|
|
res.status(200).json(rows);
|
|
}
|
|
);
|
|
}; |