// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { OkPacket, RowDataPacket } from "mysql2";
import type { NextApiRequest, NextApiResponse } from 'next';
//import {BasicOrder, Order, OrderWithDetails} from "../../server/types/order";
import { db } from "../../server/db/connect";

type Data = {
    insertId: string[],
}
var data ;
export default function handler(
    req: NextApiRequest,
    res: NextApiResponse<Data>)
    {
        const queryString = "SELECT * FROM products";
        db.query(
            queryString,
            (err, result) => {
             // if (err) {callback(err)};
                const insertId = (<OkPacket> result);
            //  callback(null, insertId);
            console.log(result)
            data = result;
            res.status(200).json(insertId);
            }
          );
    };