在节点JS中编写params api的正确方法
app.post('//scripts/:freezeid',scriptsview.findall);
app.post('/scripts/deletescripts',scriptsview.deleteconfig);
是唯一的第二个API需要在params API之上写入或其他任何想法的方式在节点JS中可用
app.post('/scripts/:freezeId', scriptsView.findAll);
app.post('/scripts/deleteScripts', scriptsView.deleteconfig);
Is the only way the second API needs to write on top of the params API or any other ideas are available in node js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Express试图按顺序匹配路线。
因此,通常,url
/scripts/deletescripts
将匹配'/scripts/:freezeid'
并运行scriptsview.findall
。然后scriptsview.findall
将发送响应并结束该请求的处理。现在,
scriptsview.findall
可以特殊情况 deletescripts 和调用 next()而不是,但这意味着>
scriptsview.findall
必须了解其职责之外的内容。首先对更改顺序
'/scripts/deletescripts',首先测试
更清晰。Express tries to match routes in order.
So, typically, the URL
/scripts/deleteScripts
will match'/scripts/:freezeId'
and runscriptsView.findAll
. ThenscriptsView.findAll
will send a response and end the handling of that request.Now,
scriptsView.findAll
could special casedeleteScripts
and callnext()
instead, but that meansscriptsView.findAll
has to know about things outside its remit.Changing the order so
'/scripts/deleteScripts',
is tested first is clearer.而不是
app.post
您可以使用app.delete
dellete脚本APIInstead of
app.post
you can useapp.delete
for delete scripts API