반응형
POST REQUEST
app.use(express.urlencoded({ extended: true }));
app.post("/blogs", (req, res) => {
const blog = new Blog(req.body);
blog
.save()
.then((result) => {
res.redirect("/blogs");
})
.catch((err) => {
console.log(err);
});
});
반응형
'Node.js' 카테고리의 다른 글
[Node.js] 1. Course Structure and Projects (0) | 2024.02.03 |
---|---|
Node.js Crash Course Tutorial #11 - Express Router & MVC (2) | 2023.10.03 |
Node.js Crash Course Tutorial #9 - MongoDB (0) | 2023.10.02 |
Node.js Crash Course Tutorial #8 - Middleware (0) | 2023.09.30 |
Node.js Crash Course Tutorial #7 - View Engines (0) | 2023.09.30 |