Answers for "how to handle request paths in express js"

2

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)
});
Posted by: Guest on August-12-2020

Code answers related to "how to handle request paths in express js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language