Answers for "get url params in express"

10

express get url parameters

app.get('/path/:name', function(req, res) {
  res.send("tagId is set to " + req.params.name);
});
Posted by: Guest on July-03-2020
15

express get query params from url

GET /something?color1=red&color2=blue

app.get('/something', (req, res) => {
    req.query.color1 === 'red'  // true
    req.query.color2 === 'blue' // true
})
Posted by: Guest on July-03-2020
2

get url params in express

app.get("/users/:id",(req,res)=>{ // https://domain.com/users/817178
  const id = req.params.id ; //  817178
})
app.get("/users?name=anas",(req,res)=> { // https://domain.com/users?name=anas
const name  = req.query.name ; //anas
})
Posted by: Guest on April-22-2021
5

node js express url parameters

// http://localhost:8080/api/1
app.get('/api/:version', function(req, res) {
    res.send(req.params.version);
});
Posted by: Guest on October-11-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language