fix: use await to wait for map
This commit is contained in:
parent
2c01512c53
commit
24a12ea3b1
@ -58,9 +58,11 @@ const getBox = async (idOrTitle: number | string): Promise<Either<Box, string>>
|
||||
const getAllBoxes = async () => {
|
||||
const client = new_client();
|
||||
await client.connect();
|
||||
|
||||
const res = await client.query("SELECT * FROM boites");
|
||||
|
||||
await client.end();
|
||||
return res.rows.map(db2box);
|
||||
return await Promise.all(res.rows.map(async (el) => { return await db2box(el) }));
|
||||
}
|
||||
|
||||
const getAllBoxesFromDate = async (date: Date) => {
|
||||
@ -73,8 +75,9 @@ const getAllBoxesFromDate = async (date: Date) => {
|
||||
const dateString = `${YYYY}-${MM}-${DD}`;
|
||||
|
||||
const res = await client.query("SELECT * FROM boites WHERE date_boite > $1", [dateString]);
|
||||
|
||||
await client.end();
|
||||
return res.rows.map(db2box);
|
||||
return await Promise.all(res.rows.map(async (el) => { return await db2box(el) }));
|
||||
}
|
||||
|
||||
const boxService = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user