function getAllCustomers() {
const pool = new sql.ConnectionPool(config);
const request = new sql.Request(pool);
try {
pool.connect(function () {
request.query('select * from Customers', function (err, res) {
console.log(res.recordset);
return res.recordset;
});
});
} catch (error) {
console.log(error);
}
return;
}
我顺利地将 res.recordset 打印到控制台,但是当我想从函数返回这个值时,返回 null。我该怎么办?