express request path code example
Example 1: express request path
app.get('/admin', (req, res, next) => {
req.originalUrl;
req.baseUrl;
req.path;
req.baseUrl + req.path;
});
Example 2: express redirect
res.redirect('/foo/bar')
res.redirect('http://example.com')
res.redirect(301, 'http://example.com')
res.redirect('../login')
Example 3: node js http request express
npm install request@2.81.0
Example 4: express render
res.render('index')
res.render('index', function (err, html) {
res.send(html)
})
res.render('user', { name: 'Tobi' }, function (err, html) {
})