title: Waiting for function result
body: <p>How should I refactor this code to properly wait for _getWorkerId function and its result?</p>
  
  <pre><code>var EventsPersistancyService = {
    accept: function acceptService(msg) {
  
      function _getAppCategory() {
      }
  
      function _getWorkerId(user_sid, login) {
        Worker.findByLogin(login, function(res){
  
        });
      }
  
      var content = msg.content.toString();
      content = JSON.parse(content);
      content["app_category"] = _getAppCategory();
      content["worker_id"] = _getWorkerId();
  
      Event.create(content).then(function (x) {});
    }
  }
  </code></pre>