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]);
});
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter