in node.js i have a function A in which i call another function B. Function B returns an array which i need to continue in function A. However function A doesn't wait for the return value and continues. How can i manage function A to wait for the return value of function B?
functionA(param1, param 2) {
//some code
var content = functionB(argument);
//some more code which needs return of functionB
}
functionB(argument) {
//some more code
bot.page(t).complete(function (title, text, date) {
var str = S(text).between('== Kurzbeschreibung ==\n* ', '.').s;
var content = {};
str = parseTitles(str); //calls antoher function which splits a long string into an array
content.Owner = str[0];
content.Aim = str[1];
content.What = str[2];
content.Who = str[3];
content.Steps = str[4];
content.Page = 'anyurl';
return content;
}
});
}
Right now function A is not waiting until function B is finished and returns it's Value.