I don't like to ask a question but I feel I need to know how, or a better way of doing this. I should say first that I'm new to Javascript having done Java before and am new to callbacks as well. I read some other questions, but am still having some difficulty. This is truly horrible.
In rounds.js I have this
exports.getCurrentRound = function(callback) {
exec(header + token + address, function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
rounds = stdout;
if (error !== null)
callback(null, err);
else
callback(null, currentRound);
});
}
In index.js I have this.
var result;
rounds.getCurrentRound( function (err, cr) {
currentRound = cr;
console.log("the current round is" + currentRound);
});
How can i get result to equal something? Hope that makes sense. Keep in mind i'm running windows. And am reluctant to use promises. Whatever that is. I hope I'm not wasting your time too much.
Thanks.
Alternatively if there's a way to just run this synchronously please tell me what it is. I just want to know the proper way of doing this.