You have flow control issues. Remember javascript is asynchronous. getData returns undefined before your mysql query completes.
var async = require('async');
//common callback convention is too pass in parameters and a callback function
//callback function has the signuature (error, values)
//if error is set you need to handle it.
var getData = function (param, next) {
//escape your query. You don't want a sql injection
pool.query('SELECT value FROM data where config like %?%', param, function (err, rows) {
//return here does nothing. It is to break execution if there is an error.
if (err) { return next(err); }
//process your data here or just return it.
//notice the null means no error
next(null, rows[0].value);
});
};
//chose series, parallel, or waterfall depending on what you need to do
async.parallel([
function (cb) {
getData('countdown', function (err, data) {
cb(err, data * 1000);
});
},
function (cb) {
getData('balltime', function (err, data) {
cb(err, data * 1000);
});
},
function (cb) {
getData('pausetime', function (err, data) {
cb(err, data * 1000);
})
}
], function (err, results) {
if (err) { throw err; //handle error}
//this is timeoutEstrazione.
console.log(results[0]);
});
This is a quick and dirty example, but your issues come from flow control. Javascirpt does not return things the way you think it will.
Good luck.