[英]How do I set up an express route where parameters have multiple slashes?
我正在尝试设置如下端点:
http://localhost:5000/guardian/lifeandstyle/2020/apr/26/bring-your-skin-to-life-with-a-hint-of-bronzer
我目前这样设置我的端点:
router.get('/guardian/:articleId', (req, res) => {
const id = req.params.articleId;
console.log(id);
axios.get('https://content.guardianapis.com/'+ id +'?api-key=' + guardianapi + '&show-blocks=all')
.then(function (response) {
res.send(response.data);
});
});
但是,一旦我在浏览器中输入端点,就会收到 404 错误
请参阅有示例的指南:
app.get('/users/:userId/books/:bookId', function (req, res) { res.send(req.params) })
您只需在路线中放置多个/
并以:
开头的多个名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.