has the following code:
let result = {
data: {
values: [],
}
};
try {
let baseInfo = await baseinfoModel.getSystemInfo();
if (baseInfo === null) {
return null;
} else {
baseInfo.forEach(function (doc) {
result.data.values.push({
objectid: doc._id,
system: doc.system,
});
}, function (err) {
if (err) {
throw err;
}
})
return result;
}
} catch (err) {
throw err;
}
here comes the problem: result data is stored in forEach, but the external definition of result has not changed. How can you pass forEach data to external variables?