Javascript 如何将数据从异步函数传递到ejs?
我有一个问题,涉及到使用异步函数从数据库获取数据。我试过:Javascript 如何将数据从异步函数传递到ejs?,javascript,express,ejs,Javascript,Express,Ejs,我有一个问题,涉及到使用异步函数从数据库获取数据。我试过: server.get("/profile/:id", async(req, res) => { const profile = await findPerson(req.params.id) res.render('profile', { profile: profile}) }) 我还尝试了其他几种方法,如使用.then()和使函数同步,但始终存在一个EJS错误,即: Unexpected
server.get("/profile/:id", async(req, res) => {
const profile = await findPerson(req.params.id)
res.render('profile', { profile: profile})
})
我还尝试了其他几种方法,如使用.then()和使函数同步,但始终存在一个EJS错误,即:
Unexpected token 'catch' in C:\Users\lol\Desktop\proj\views\profile.ejs while compiling ejs
对于这类事情,最好的解决方案是什么
编辑:EJS不会真正弹出错误,但以下是我的EJS代码:
轮廓
此配置文件不可用
配置文件存在
```
我看不出您显示的代码有任何问题。EJS文件中的错误具体发生在哪里?