我无法渲染我的EJS文件。选项卡只是加载和加载。一旦我停止了Nodemon,它就会渲染

发布于 2025-02-01 11:59:33 字数 789 浏览 1 评论 0原文

我正在app.get(“/user/:u_id)

app.get("/user/:U_ID", function(req, res) {
    console.log(req.params.U_ID);
    User.find({_id: req.params.U_ID}, function(err, foundList) {
    if(!err) {
    if(foundList) {
        console.log(foundList);
        res.render("dashboard.ejs", {user: foundList[0]});
    }
    } else {
        // alert("Something went wrong");
        res.redirect("/");
    }
  });
});

。 中找到用户后,我想渲染的EJS。

从数据库 和我的Chrome Tab

当它到达res.render(...)的线时,它只是开始加载,加载和加载。 当我停止我的Nodemon或再次使用App.js使用ctrl+SNodemon再次保存app.js重新启动服务器,然后将我的dashboard.ejs渲染。

请帮助。如何渲染dashboard.ejs

I am searching for a particular user in app.get("/user/:U_ID). Below is the code for it.

app.get("/user/:U_ID", function(req, res) {
    console.log(req.params.U_ID);
    User.find({_id: req.params.U_ID}, function(err, foundList) {
    if(!err) {
    if(foundList) {
        console.log(foundList);
        res.render("dashboard.ejs", {user: foundList[0]});
    }
    } else {
        // alert("Something went wrong");
        res.redirect("/");
    }
  });
});

I am finding that user too in my database. But I am not able to render the ejs that I want to render after finding the user from database.

Here is the code, its output in console and my chrome tab

When it reaches to the line of res.render(...), it just starts to load, load and load.
When I am stopping my nodemon or I am again saving the app.js with CTRL+S, nodemon again restarts the server, then my dashboard.ejs gets rendered.

Please help. How to render the dashboard.ejs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文