Every time I make a post request, the page just loads forever and the DB remains unfilled. Where am I going wrong? Cause it had worked the first time around, now it’s just forever loading.
server file:
app.post("/compose", function (req, res) {
const day = date.getDate();
const newNote = new Note({
title: req.body.title,
subtitle: req.body.subtitle,
categories: req.body.category,
thesis: req.body.thesis,
note: req.body.note,
summary: req.body.summary,
author: req.body.author,
dateCreated: day,
googleId: req.user.googleId
});
newNote.save(function(err) {
if (!err) {
res.redirect("/home");
}
});
});
view file:
<form class="" action="/compose" method="POST">
<div class="form-group">
<label>Title</label>
<input class="form-control" type="text" name="title">
<label>Subtitle</label>
other inputs and labels..
</div>
<button class="btn btn-primary" type="submit" name="button">Publish</button>
</form>