feat: update getAll25 function to return consistent response format and modify frontend route to handle async data retrieval
This commit is contained in:
@@ -14,8 +14,8 @@ const pool = mysql
|
||||
export const getAll25 = async () => {
|
||||
const [rows] = await pool.query("SELECT unique_key FROM users");
|
||||
if (rows.length > 0) {
|
||||
return rows;
|
||||
return {rows};
|
||||
} else {
|
||||
return "No data found";
|
||||
return { message: "No data found" };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,10 +5,11 @@ dotenv.config();
|
||||
|
||||
import { getAll25 } from "./frontend.data.js";
|
||||
|
||||
router.post("/frontend", (req, res) => {
|
||||
router.post("/frontend", async (req, res) => {
|
||||
console.log(req.body);
|
||||
res.status(200).json({ message: "Data received successfully" });
|
||||
console.log(getAll25());
|
||||
const data = await getAll25();
|
||||
console.log(data);
|
||||
res.status(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user