express route and wildcards using req.params;

PHOTO EMBED

Tue Aug 31 2021 05:43:33 GMT+0000 (Coordinated Universal Time)

Saved by @faisals #node

const monsters = { 
  hydra: { height: 3, age: 4 }, 
  dragon: { height: 200, age: 350 } 
};
// GET /monsters/hydra
app.get('/monsters/:name', (req, res, next) => {
  console.log(req.params)' // { name: 'hydra' }
  res.send(monsters[req.params.name]);
});
content_copyCOPY