I'm a newbie in Node.js and I'm trying to call a function after a select query with the following code:
private getUsersList(): any {
let con = this.connect();
con.connect(function(err: any) {
if (err) throw err;
let sql = 'SELECT * FROM my_table WHERE 1';
return con.query(sql, function(this: any, error: any, result: any) {
if(err) throw error;
return result;
});
});
}
private showUsers()
{
let usersList = this.getUsersList();
user.prompt("GetUserList: " + usersList);
}
When I call showUsers it displays an empty array. I don't know why, and how could I fix it.