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 getAllBoxes = async () => {
|
||||||
const client = new_client();
|
const client = new_client();
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
|
||||||
const res = await client.query("SELECT * FROM boites");
|
const res = await client.query("SELECT * FROM boites");
|
||||||
|
|
||||||
await client.end();
|
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) => {
|
const getAllBoxesFromDate = async (date: Date) => {
|
||||||
@ -73,8 +75,9 @@ const getAllBoxesFromDate = async (date: Date) => {
|
|||||||
const dateString = `${YYYY}-${MM}-${DD}`;
|
const dateString = `${YYYY}-${MM}-${DD}`;
|
||||||
|
|
||||||
const res = await client.query("SELECT * FROM boites WHERE date_boite > $1", [dateString]);
|
const res = await client.query("SELECT * FROM boites WHERE date_boite > $1", [dateString]);
|
||||||
|
|
||||||
await client.end();
|
await client.end();
|
||||||
return res.rows.map(db2box);
|
return await Promise.all(res.rows.map(async (el) => { return await db2box(el) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
const boxService = {
|
const boxService = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user