How can I make node js synchronize?

I used promise as suggested but still I have a problem that I can console.log my array.

here is what I did:

exports.getData = function(request, response) {

userEmail = request.body.user;

function delay(ms){ // takes amount of milliseconds
return new Promise(function(resolve, reject){
setTimeout(function(){ // when the time is up
resolve(); // change the promise to the fulfilled state
}, ms);
});
}