I am currently using this mssql client and I am trying to make 2 queries and passing both results in a function but I can't get the result of my query outside of the scope, even if i use a global variable. I am guessing it is because I only have a reference and I lose it when the function returns? How should I go about this? Here is my code of 1 working query but I am not able to add a 2nd one:
function Query() {
var err, result, sql = require('mssql');
const connection = new sql.ConnectionPool(config);
var req = new sql.Request(connection);
var queryString = // String of my query //
connection.connect(function (err) {
if (err) {
console.log(err);
return;
}
req.query(queryString, function (err, result){
if (err) {
console.log(err);
}
else {
someFunc(result);
}
connection.close();
return;
});
});
}
To clarify, I would like to be able to make a 2nd query, combine both results and call someFunc() passing both results. Anyone have an idea how to go about this?