node.js – Passing info from psql to ejs using async


I want to pull from a PSQL database with pg and display the info into a table. I have been able to pull the data and display as an object (? all of the data displays with the endpoint that I used below to test) with promises and async but cannot work out how to send it to EJS to render.

//using async/await
router.route('/')
    .get(async function (req, res) {      
        try {
            let accountList = await createALb();
            res.send(accountList);
            //res.render('/accountList', {'accountList': accountList})
        }
        catch(err) {
            res.status(500).send(err)
        }
    });


async function createALb() {
    const client = await pool.connect()
    const data = await client.query(select)
    client.release()
    //console.log(data) - this is returning the object, it's working homie
    return data
    
}
   
module.exports = router;

server.js

const accountList = require('./pgpooling');
//const accountList = require('./accountList.json'); - I can access this info and manipulate into a table

//setup view engine
app.engine("ejs", ejsEngine);
app.set("view engine", "ejs");

//this is sending the right information
app.use('/accountList', accountList)

app.get('/', (req, res) => {
   res.render("ejs/index");
});

Any time I try to access in EJS with:

<%- accountList.rows(0).account_name %>

or similar, it throws a “accountList is not defined” error.

What am I doing wrong?

Thanks