Expecting both "name" and "character" on each post to the /register
API. Also add a /players API to list the players registered so far.
const app = express();
+const players = [];
+
app.use(body_parser.urlencoded({ extended: false }));
app.use(body_parser.json());
res.send('Hello World!');
});
+app.get('/players', function (req, res) {
+ res.send(players);
+});
+
+
app.post('/register', function (req, res) {
- console.log(req.body);
+ players.push({name: req.body.name,
+ character: req.body.character});
+ res.send();
});
app.listen(3000, function () {