From 3dc0482614e7f38648ea63b43f68c9eaa99883cb Mon Sep 17 00:00:00 2001 From: Jake Runzer Date: Wed, 7 Oct 2020 13:25:18 -0600 Subject: [PATCH] use async await in nextjs example --- javascript/with-next-js/pages/api/data.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/javascript/with-next-js/pages/api/data.js b/javascript/with-next-js/pages/api/data.js index 3fd1836..84c8b7e 100644 --- a/javascript/with-next-js/pages/api/data.js +++ b/javascript/with-next-js/pages/api/data.js @@ -3,13 +3,14 @@ // Call Railway anywhere on serverside code. // Here or getInitialProps -import { promisify } from "util"; import pg from "pg"; +const client = new pg.Pool(); + export default async (req, res) => { try { - const client = pg.Pool(); - const query = await promisify(client.query)("Select NOW()"); + const query = await client.query("SELECT NOW()"); + res.json({ data: { time: query.rows[0].now,