Skip to content

Commit 3fa0bb2

Browse files
committed
[Gordon] added example on body parser
1 parent 0b12ff6 commit 3fa0bb2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

body-parser-example.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const express = require("express");
2+
const app = express();
3+
const bodyParser = require("body-parser");
4+
5+
app.use(bodyParser.json());
6+
7+
app.post("/users", function(req, res) {
8+
const userName = req.body.name;
9+
res.send(`${userName} is created.`);
10+
});
11+
12+
const server = app.listen(3000, function() {
13+
console.log("Application started....");
14+
});

0 commit comments

Comments
 (0)