1// GET 'http://www.example.com/admin/new?a=b'
2app.get('/admin', (req, res, next) => {
3 req.originalUrl; // '/admin/new?a=b' (full path with query string)
4 req.baseUrl; // '/admin'
5 req.path; // '/new'
6 req.baseUrl + req.path; // '/admin/new' (full path without query string)
7});
1var express = require('express')
2
3var app = express()
4
5app.use(express.json()) // for parsing application/json
6app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
7
8app.post('/profile', function (req, res, next) {
9 console.log(req.body)
10 res.json(req.body)
11})
12