I'm trying to deploy an app into Heroku but it doesn't work.
When in local it renders the JSON on the screen but in Heroku, it keeps loading and after a while throws a Request timeout error. What could be causing this?
app.get("/", (req, res) => {
res.send("home");
});
app.get("/info", (req, res) => {
Person.find({}).then((result) => {
res.send(
`<div>
<p>Phonebook has info for ${result.length} people</p>
<p>Get request was made at ${new Date()}</p>
</div>`
);
});
});
app.get("/api/persons", (req, res) => {
Person.find({}).then((result) => {
res.json(result);
});
});
These are my get request, I have more but the only one that works is "/".
const personSchema = new Schema({
name: {
type: String,
minlength: 5,
required: true,
},
number: {
type: String,
minlength: 3,
required: true,
},
});
personSchema.set("toJSON", {
transform: (document, returnedObject) => {
returnedObject.id = returnedObject._id;
delete returnedObject._id;
delete returnedObject.__v;
},
});
const Person = model("Person", personSchema);