I get some data from the database, but now I want to pass them to another variable. This variable is above getData function.
var storeData;
function getData () {
connection.connect();
var query = connection.query('SELECT * FROM users', function(err, results) {
if(err) throw err;
console.log(results); // Here is OK. I have all data (results is typeof object)
storeData = results; // Not working
});
connection.end();
}
getData ();
console.log(storeData); // undefined