首页 > 解决方案 > 如何将对象数组从异步函数返回到 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 函数中的一个步骤?

标签: node.jsasynchronousmongoosepromisepug

解决方案


推荐阅读