node.js - 如何将对象数组从异步函数返回到 pug 模板?
问题描述
const Entry = mongoose.model('daily',entrySchema)
async function displayEntry(){
let data = await Entry.find()
console.log(data)
return data
}
module.exports = { displayEntry : displayEntry }
// 当我将 displayEntry 导入新文档并尝试在 pug 文档上显示数据时,我得到 [object promise]。我猜我忘记了 displayEntry 函数中的一个步骤?
解决方案
推荐阅读
- javascript - 如何在猫鼬模式中使用异步默认值?
- c - 函数声明问题,K&R问题1-15
- javascript - 检测 window.location.assign() 是否收到响应
- ios - iOS奇怪行为的通用链接
- tensorflow.js - 使用 Tensorflow.js 自定义模型访问标签和置信度值?
- c# - 按接口中定义的顺序对实现类方法进行排序
- regex - 在 Elixir 中,如何将字符串拆分为非单词字符是分隔符,但还允许使用 +、- 等数学运算符?
- python - numpy.linspace - X 轴上的错误标签
- c++ - 为什么 constexpr 的性能比正常表达式差?
- c++ - 用于向量处理的多线程