how to get id from url in express, param and query doesnt seem to work
express, node.js
Solution
Your code is working as expected: The `ajax` call specifies `url: '/test/:uid'` which is what puts `:uid` in `req.params.uid`.
Try sending something else: `url: '/test/123'` and `req.params.uid` will contain `123`
Problem
I have a url, i'm trying to get id but none of it is working req.params nor req.query ``` app.get('/test/:uid', function testfn(req, res, next) { debug('uid', req.params.uid); // gives :uid debug('uid', req.query.uid); // gives undefined }); ``` I'm doing an ajax call like this ``` $(document).on('click', 'a.testlink', function(e) { $.ajax({ type: "GET", url: '/test/:uid', success: function(var) { console.log('success'); }, error: function() { alert('Error occured'); } }); return false; }); ``` I'm using ``` app.use(express.json()); app.use(express.urlencoded()); ``` instead of body parser