当我将一个对象推入一个数组时,它可以在函数之外工作,但它又是空的!
.get(function(req, res){
//Mongoose Model
var employeeModel = require('../models/employeeModel');
var employeeList = new Array();
employeeItems = req.project.involvedEmployee;
employeeItems.forEach(function(entry) {
var employeeId = entry.employeeId;
employeeModel.findById(employeeId, function(err, employee){
if(err){
res.status(500).send(err);
}
else {
employeeList.push(employee);
}
});
});
res.json(employeeList);
});
请告诉我我的问题是什么?