How to work with the async module?

There is a module that makes a request to the database. Call it from another place but due to asynchrony, he has no time to work out. How to call it synchronously?
createExtraData function() {
 var regionList = regionsLists.getRegionsList();
 console.log(regionList) //Here is undefined, the query to the database in the module have not yet met

It is possible a code sample how to fix? I read about promises but do not understand how to use them here.
July 9th 19 at 10:22
3 answers
July 9th 19 at 10:24
All through as and!
In the settings getRegionsList transfer callback, in which you'll perform actions with the received data.
Asynchronous functions usually do not return (via return). Their task is to invoke the callback and pass it the result of function execution (in your case the query to the database).

UPD: example (your module)

module.exports.getRegionsList = function(callback)
 /*abstract an example of a DB query*/
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
July 9th 19 at 10:26
Add a module to callback
createExtraData function() {
July 9th 19 at 10:28
You nogino that come to mind:
var regionList = regionsLists.getRegionsList().then(function(data) { console.log(data) })

How to do it:

Find more questions by tags JavaScriptExpress.jsNode.js