在节点JS中编写params api的正确方法

发布于 2025-01-29 16:04:15 字数 211 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栀梦 2025-02-05 16:04:15

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 run scriptsView.findAll. Then scriptsView.findAll will send a response and end the handling of that request.

Now, scriptsView.findAll could special case deleteScripts and call next() instead, but that means scriptsView.findAll has to know about things outside its remit.

Changing the order so '/scripts/deleteScripts', is tested first is clearer.

羞稚 2025-02-05 16:04:15

而不是app.post您可以使用app.delete dellete脚本API

Instead of app.post you can use app.delete for delete scripts API

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文