1const express = require('express');
2const bodyParser = require('body-parser');
3
4const app = express();
5app.use(bodyParser.urlencoded({ extended: true }));
6
7app.post('/post-test', (req, res) => {
8 console.log('Got body:', req.body);
9 res.sendStatus(200);
10});
11
12app.listen(8080, () => console.log(`Started server at http://localhost:8080!`));
1const express = require('express');
2const bodyParser = require('body-parser');
3
4const app = express();
5app.use(bodyParser.urlencoded({ extended: true }));
6
7// POST /somepost/?name=somename
8app.post('/somepost', (req, res) => {
9 console.log('Name:', req.query.name);
10 res.status(200);
11});
1// GET /search?q=tobi+ferret
2console.dir(req.query.q)
3// => 'tobi ferret'
4
5// GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse
6console.dir(req.query.order)
7// => 'desc'
8
9console.dir(req.query.shoe.color)
10// => 'blue'
11
12console.dir(req.query.shoe.type)
13// => 'converse'
14
15// GET /shoes?color[]=blue&color[]=black&color[]=red
16console.dir(req.query.color)
17// => ['blue', 'black', 'red']
18