I'm dealing with a NodeJs framework that requires a certain function to be synchronous, but I need to retrieve a value that can only be accessed asynchronously. In a perfect world, I would be able to return a promise, but I can't.
As a quick-and-dirty solution, I created the following method:
exports.synchronizePromise = function(promise) {
var value;
promise.then(function(promiseValue) {
value = promiseValue;
});
while (!value) {} // Wait for promise to resolve
console.log("DONE: " + value); // Never reached
return value;
};
But I get an error. Is there any way to accomplish what I need?