我應該如何重構此代碼以正確地等待_getWorkerId函數及其結果?等待函數結果
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) {});
}
}
添加回調函數作爲第三個參數。 – Nonemoticoner