function getUser(id) {
return this.db.one("select *...");
}
app.get("/user/:id", (req, res) => {
getUser(req.params.id).then(data => {
// use the data
// return another promise if you need
// another async call
}).catch(err => {
// handle the error;
});
})
Comments