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 () => {
|
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" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user