express js params
app.get('/path/:name', function(req, res) {
res.send("tagId is set to " + req.params.name);
});app.get('/path/:name', function(req, res) { // url: /path/test
console.log(req.params.name); // result: test
});
// OR
app.get('/path', function(req, res) { // url: /path?name='test'
console.log(req.query['name']); // result: test
});app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
Route path: /users/:userId/books/:bookId
Request URL: http://localhost:3000/users/34/books/8989
req.params: { "userId": "34", "bookId": "8989" }
Also in JavaScript:
- usestate hook
- js root url
- jquery toggle show hide
- Truthy and Falsy js
- dynamically add id ro div in angular using forloop ngfor
- js dictionary
- how to learn javascript
- export app react native
- how to change zoom in and zoom out button position in google map
- javascript check if string is number
- insert element after element javascript
- file ajax
- js hoisting
- input in js
- jquery validate conditional
- javascript get string from array with space between
- inmutabilidad javascript
- javascript async await returns undefined
- get caret index js
- how to translate english to hindi after enter space using javascript
- javascript uppercase first character of each word
- loopback model count
- force click btn using jquery
- capture enter button react input