Having troubling creating a callback.
Example:
var connection = new sql.Connection(config);
connection.connect().then(function() {
var request = new sql.Request(connection); // or: var request = connection.request();
request.query('SELECT TOP 1 EQUIPMENT_ID FROM T_EQUIPMENT', function(err, recordset) {
console.dir(recordset);
});
}).catch(function(err) {
// ...
});
Using npm mssql:
I need to make sure I have this data prior to continuing my next task.
So lets say after this I have something like:
console.log("completed");
Because it is async, the "completed" will come first, then the query.
How do properly create a callback so that when it is completed then process the next task without having to "nest" within the request.
If it's not possible let me know, I just want to make sure I am doing best practices.
Thank you very much!