api.js:
var db = require('./db.js');
console.log(searchAccessToken(name,queryDB));
searchAccessToken function:
function searchAccessToken(emailAddress,callback){
    var sql = "SELECT accessToken FROM device WHERE email_address = '" + emailAddress + "'";
    return callback(sql);
}
queryDB function:
function queryDB(sql){
    var token = "";
    db(function(err,conn){
        conn.query(sql,function(err,results){
            if(err){
                conn.release();
                return err;
            }else if(results.length){
                token = results[0].accessToken;
            }
            conn.release();
            return token;
        });
    });
}
db.js
var mysql = require('mysql');
var pool = mysql.createPool({
  //development
  // host:'localhost',
  // user:'root',
  // password: '',
  // database: 'merchantdev',
  // insecureAuth : true
  //staging
  host:'',
  user: '',
  password: '',
  database: ''
});
var getConnection = function(callback) {
  pool.getConnection(function(err, connection) {
      if(err) {
        return callback(err);
      }
      callback(null, connection);
  });
};
module.exports = getConnection;
I have read the other thread in SOF (How do I return the response from an asynchronous call?) but still unable to find out the mistake in my code. Please do not close this question as I have struggled for hours to find the solution but still couldn't. Console.log returns undefined when it is supposed to return a value. 
 
     
    