node js express get request code example
Example 1: node js express url parameters
// http://localhost:8080/api/1
app.get('/api/:version', function(req, res) {
res.send(req.params.version);
});
Example 2: node js http request express
npm install [email protected]
Example 3: express route parameters
Route path: /flights/:from-:to
Request URL: http://localhost:3000/flights/LAX-SFO
req.params: { "from": "LAX", "to": "SFO" }
Example 4: express get
app.get('/index', (req, res) => {
res.render('index')
})