【发布时间】:2021-11-20 00:34:09
【问题描述】:
const images = await tbl
.find({
creator_id: req.user._id,
})
.select({
creator_id: 0,
})
.then((images) =>
images.forEach((image) => {
image.file_name = process.env.IMAGE_HOST_URL + image.file_name;
})
);
它在 .then 位中失败。不知道为什么。
【问题讨论】:
-
您遇到了什么错误?你可以分享一些日志
-
其实不是抛出错误,而是返回一个空数组。这不是预期的。没有
.then位,列表不为空。 -
您正在使用
await和then。使用一个或另一个。 -
啊,我想我知道为什么了。删除第一行的等待。或突破 .then 以自行发生。我会发布一个答案。
标签: javascript node.js mongodb express mongoose