Cannot response while sending from .ejs

I’m here for help with my Glitch project, the problem is that my project’s website is still loading when trying to response from .ejs file (response.render()) and then it returns with “Site didn’t respond”. Other things like response.sendFile works fine. What do I do?
Here’s my code:

const express = require("express");
const app = express();
const client = require("./index.js")
const ejs = require("ejs")
const dreams = [
  "Find and count some sheep",
  "Climb a really tall mountain",
  "Wash the dishes"
]; // noob
app.set('view engine', 'ejs');
app.use(express.static("public"));

app.get("/", (request, response) => {
 // response.sendFile(__dirname + "/views/index.html");
  response.render("index", client, {async: true})
});

// listen for requests :)
const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

Hi @raluvy95,

Could you share your project name so we can take a closer look?

my project is caramel-amusing-kumquat

Hey @raluvy95,

I remixed your app, and was able to get the view to show by doing the following steps:

  1. I updated the render to:
app.get("/", (request, response) => {
  response.render("index")
})
  1. I went to index.ejs and added some content to the file. Then it loaded as expected.

Can you give that a try and let me know how it goes?

2 Likes