Created
October 19, 2018 00:02
-
-
Save myyellowshoe/add1a17e12961e3cdd852f45f1ba5944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/', (req, res) => { | |
const client = new Client(); | |
client.connect() | |
.then(() => { | |
const sticky = await client.query("SELECT * FROM product_index WHERE product_sticky::boolean = 'true'") | |
.then((results) => results.rows); | |
const lowstock = await client.query("SELECT * FROM product_index WHERE product_sticky::boolean = 'true'"); | |
.then((results) => results.rows); | |
return { sticky, lowstock }; | |
}) | |
.then((results) => { | |
console.log('results?', results); | |
client.end(); | |
res.render('home', results); | |
}) | |
.catch((err) => { | |
console.log('error'. err); | |
client.end(); | |
res.send('Something bad happened'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment