diff --git a/src/app.ts b/src/app.ts index 947ad92..f9bfa2a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -9,7 +9,8 @@ app.use(express.json()); app.get("/api/getRequests", async (request, response) => { var requestCount = ( request.query.count ? parseInt(request.query.count as string, 10) : 5 ); - requests.getRequests(requestCount,response); + requests.getRequests(requestCount).then((val: any) => console.log(val)); + response.send(requests.getRequests(requestCount)); }); app.get("/api/getAllRequests", async (request, response) => { diff --git a/src/requests.ts b/src/requests.ts index ab4c784..a056da1 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -8,10 +8,10 @@ const getRequestsQuery = { text: "SELECT * FROM requests_vw LIMIT $1" } -export async function getRequests(count: number, response: express.Response) { +export async function getRequests(count: number) { var query = Object.assign(getRequestsQuery, { values: [count] }); db.query(query) - .then((result: pg.QueryResult) => response.send(result.rows)) + .then((result: pg.QueryResult) => result.rows) .catch((e: any) => console.error(e.stack)); };