How to continue the function only after obtaining the values from another?

When calculating call the function
pr2.result = + mailBoxFunctional(pr2,pr1);

The function uses the SetTimeout:
mailBoxFunctional function (receiver, sender) {
 var message = `${} requested data ${}`;
 var getData = sender.GetData(sender);
 var message2 = `${} sent to the mailbox of the process ${}`;
 setTimeout(function (argument) {
 return getData 
 } , 5000);

Of course, out undefined, because the calculation occurs before obtaining a value from a function.
How to fix it?
July 2nd 19 at 13:09
1 answer
July 2nd 19 at 13:11

Find more questions by tags JavaScript