When I do console.log(users) it gives me the desired output (array of objects) but with a Promise around it like this:
Promise {
[
{user1, ....},
{user2, ....},
{user3, ....},
]
}
How do I make this Promise go away? Check code down below.
Thanks in advance from a newbie.
async function getUsers(query){
try{
const results = await client.query(query);
const data = results.rows;
console.log("data",data)
return data;
} catch(err) {
console.log(err.stack);
}finally{
client.end();
}
}
const users = getUsers(`Select * from users;`);