0

Here is how I call postgres from my node.js app using express

const db_pg = require("./db-pg");
app.get('/pg/', (req,res,next) => {
    db_pg.query(req).then((body) => {
        res.send(body);
    }).catch((err) => {
        next(err);
    })
});

And within my db-pg/index.js file (not including the detail of the pool setup):

module.exports = {
    query: (req) => {
        return pool.query(req);
    }
};

I am getting the following error from postgreSQL :

syntax error at or near ","

The query I am trying to execute is :

req = {
    text: "SELECT * from my_func(?,?,?)",
    values: ["the_name", 20190303, 20190620]
}

What is wrong in my syntax ?

0

It should be like below.

req = {
    text: "SELECT * from my_func(?,?,?)",
    values: ["the_name", 20190303, 20190620]
}
  • wish it were that simple. typo fixed in the question – Chapo Apr 29 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.