1app.get('/path/:name', function(req, res) {
2 res.send("tagId is set to " + req.params.name);
3});
1app.get('/users/:userId/books/:bookId', function (req, res) {
2 res.send(req.params)
3})
4
1Route path: /users/:userId/books/:bookId
2Request URL: http://localhost:3000/users/34/books/8989
3req.params: { "userId": "34", "bookId": "8989" }
4
1app.get('/',function(req,res)
2{
3 res.send("Route path at base address");
4});
1Route path: /flights/:from-:to
2Request URL: http://localhost:3000/flights/LAX-SFO
3req.params: { "from": "LAX", "to": "SFO" }
4
1var express = require('express');
2var http = require('http');
3var app = express();