1app.get('/path/:name', function(req, res) {
2 res.send("tagId is set to " + req.params.name);
3});
1app.get("/users/:id",(req,res)=>{ // https://domain.com/users/817178
2 const id = req.params.id ; // 817178
3})
4app.get("/users?name=anas",(req,res)=> { // https://domain.com/users?name=anas
5const name = req.query.name ; //anas
6})
1// http://localhost:8080/api/1
2app.get('/api/:version', function(req, res) {
3 res.send(req.params.version);
4});
1Route path: /users/:userId/books/:bookId
2Request URL: http://localhost:3000/users/34/books/8989
3req.params: { "userId": "34", "bookId": "8989" }
4
1URL Parameters
2These are information that are passed through the URL like so:
3
4http://example.com/api/users?id=4&token=sdfa3&geo=us