// POST ROUTE
app.post("/chats", async (req, res,next) => {
try {
let { from, to, msg } = req.body;
let newchat = new Chat({
from: from,
msg: msg,
to: to,
created_at: new Date(),
});
await newchat.save();
res.redirect("/chats");
} catch (err) {
next(err);
}
Comments
Post a Comment