feat: update getAll25 function to return consistent response format and modify frontend route to handle async data retrieval

This commit is contained in:
2026-01-13 19:51:12 +01:00
parent 110a5b17c2
commit 28c3c119f1
2 changed files with 6 additions and 5 deletions

View File

@@ -14,8 +14,8 @@ const pool = mysql
export const getAll25 = async () => { export const getAll25 = async () => {
const [rows] = await pool.query("SELECT unique_key FROM users"); const [rows] = await pool.query("SELECT unique_key FROM users");
if (rows.length > 0) { if (rows.length > 0) {
return rows; return {rows};
} else { } else {
return "No data found"; return { message: "No data found" };
} }
}; };

View File

@@ -5,10 +5,11 @@ dotenv.config();
import { getAll25 } from "./frontend.data.js"; import { getAll25 } from "./frontend.data.js";
router.post("/frontend", (req, res) => { router.post("/frontend", async (req, res) => {
console.log(req.body); console.log(req.body);
res.status(200).json({ message: "Data received successfully" }); const data = await getAll25();
console.log(getAll25()); console.log(data);
res.status(200);
}); });
export default router; export default router;