I'm trying to make a function which returns the user's balance. However, the function returns undefined. I've checked all the solutions on stackoverflow but I wasn't able to find a solution.
Return func
    async function checkBal(username) {
        db.getConnection(async (err, connection) => {
            if (err) throw (err)
            let queryBal = `SELECT balance FROM user WHERE username = "${username}";`
            connection.query(queryBal, async (err, result) => {
                if (err) throw (err)
                if (result.length != 0) {
                    const data = result[0].balance
                    return data               
Function from which I'm calling
    app.post("/api/bet", urlencodedParser, async function(req, res){ 
        ssn = req.session;
        if (ssn.username) {
            balance = await checkBal(ssn.username)
            console.log(balance)
 
    