如何解决在 URL 中发送数据时无法进入 GET 请求
我正在使用邮递员测试我的 API,当我尝试在 URL 中发送数据时,邮递员响应 404 Not found。我猜它的格式,但四处搜索我认为它是正确的。谁能给点灯?
但是当我不在 URL 中发送任何数据时,它工作得很好:
当我没有发送任何数据时,请求工作正常(它崩溃了,但因为它还没有完成):
解决方法
我猜您是在使用 Express.js 来构建 API,对吗?
我认为您以错误的方式使用 req.params
。
如果你想要参数名称device
您必须在 url 路径中使用 :device
而不是 :{device}
。
像这样
app.get("/mediciones/sigfox_libelium/:device",(req,res) => {
cosnt { device } = req.params // You can get device here
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。