diff --git a/src/app.ts b/src/app.ts index f9bfa2a..ef6f8a8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,15 +2,15 @@ import * as config from "./config"; import * as requests from "./requests"; import express from "express"; import db from "./db"; +import { QueryResult } from "pg"; const app = express(); app.use(express.static('public')); 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).then((val: any) => console.log(val)); - response.send(requests.getRequests(requestCount)); + var requestCount = ( request.query.count ? parseInt(request.query.count as string, 10) : 5 ); + requests.getRequests(requestCount).then((val: QueryResult) => response.send(val)); }); app.get("/api/getAllRequests", async (request, response) => { diff --git a/src/requests.ts b/src/requests.ts index a056da1..d0a7272 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -10,7 +10,7 @@ const getRequestsQuery = { export async function getRequests(count: number) { var query = Object.assign(getRequestsQuery, { values: [count] }); - db.query(query) + return db.query(query) .then((result: pg.QueryResult) => result.rows) .catch((e: any) => console.error(e.stack)); };