express js api code example
Example 1: express request path
// GET 'http://www.example.com/admin/new?a=b'
app.get('/admin', (req, res, next) => {
req.originalUrl; // '/admin/new?a=b' (full path with query string)
req.baseUrl; // '/admin'
req.path; // '/new'
req.baseUrl + req.path; // '/admin/new' (full path without query string)
});
Example 2: express api
app.render('email', function (err, html) {
// ...
})
app.render('email', { name: 'Tobi' }, function (err, html) {
// ...
})