I want to call an async function (some REST call), that returns a promise. I need the result of the promise to continue, until then my code should wait.
Now I know this is not state-of-the-art anymore, but I have to use ES 5, so no async await.
Maybe I'm going about this all wrong so far, but my current state looks something like this:
var someAsyncCall = function() {
  var deferred = $.Deferred();
  deferred.resolve.apply(deferred, ['2']);
  return deferred.promise();
};
// Call the async service
var getValue = function () {
  var result = null;
  someAsyncCall().then(function (value) {
    result = value;
  });
  return result;
};
// Synchrounus code which needs to be executed in this order.
console.log('1');
var result = getValue();
console.log(result);
console.log('3');<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>