I have the following function and I want it to return the variable recordset
, or more accurately I want to be able to access that info from the code that calls the getData()
function. How can I do this?
function getData() {
sql.connect("mssql://username:password@localhost/mytestdatabase").then(function () {
return new sql.Request().query('select * from _table')
.then(function (recordset) {
console.log(recordset); // <-- THIS IS WHAT I WANT TO RETURN
})
.catch(function (err) {
console.log("Query Error: " + err);
})
}).catch(function (err) {
console.log("Connection Error: " + err);
})
};