const { Pool, Client } = require("pg");
const pool = new Pool({
user: "postgres",
host: "localhost",
database: "postgres",
password: ""
});
function one(){
pool.query(
"SELECT id, first_name as firstname, last_name as lastname FROM students_student",
(err, res) => {
let returnValue = JSON.stringify(res.rows);
console.log(returnValue)
return returnValue
}
)
}
var res = console.log(one())
console.log(res)
Just getting started with node and the pg library...
I don't understand why res is undefined in the console.log at the end of the above code (returnValue is fine). How should I be calling the function one()?