createExtraData function() {
var regionList = regionsLists.getRegionsList();
console.log(regionList) //Here is undefined, the query to the database in the module have not yet met
sendData()
}
//...
module.exports.getRegionsList = function(callback)
{
/*abstract an example of a DB query*/
db.req(callback);
/*
Assume that the function req are asynchronous and takes a callback as well.
Pass a parameter to your function. Format your as a determined signature as a and req
*/
}
createExtraData function() {
regionsLists.getRegionsList(function(regionList){
console.log(regionList);
sendData();
});
}
var regionList = regionsLists.getRegionsList().then(function(data) { console.log(data) })
Find more questions by tags JavaScriptExpress.jsNode.js