Node.js

Node.js Crash Course Tutorial #10 - Get, Post & Delete Requests

유호야 2023. 10. 3. 00:58
반응형

 

 

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);
    });
});

 

 

반응형