I am using mysql2 package. I am doing simple sql query in node. so why does it tur
public async getTests(req: Request, res: Response): Promise<void> {
const pool = await connect();
const stmt = 'SELECT test, test2 FROM testTable';
const tests = await pool.query(stmt);
res.json({ tests});
}
Query Result:
{ foo, foo1 }, ColumnDefinition { _buf: <Buffer 01 00 00 01 0a 51 00 00 02 03 64 65 66 13 61 75 72 6f 72 61 5f 61 75 64 69 74 5f 73 69 67 6e 61 6c 0a 65 6e 67 61 67 65 6d 65 6e 74 0a 65 6e 67 61 67 ... 1200 more bytes>,
Query function returns rows & fields. Please try to get rows:
const [rows] = await pool.query(stmt);
You can check below link for details. https://github.com/sidorares/node-mysql2#using-promise-wrapper