简体   繁体   English

可以使用 Knex 在 Express Middleware 中发出异步请求吗?

[英]Is it ok to make an Async Request inside Express Middleware using Knex?

I'm wondering if it is ok, and if it is standard practice, to use a async get request in a piece of middleware that validates whether or not we are trying to create a duplicate item.我想知道是否可以,如果这是标准做法,在一个中间件中使用异步获取请求来验证我们是否正在尝试创建重复项。

So basically, middleware does a get all request from table baseball teams.所以基本上,中间件可以从桌上棒球队获得所有请求。 We compare the original post request body data to make sure there are no other baseball teams with the same name (etc) before we actually post it.我们比较原始的发布请求正文数据,以确保在我们实际发布之前没有其他同名的棒球队(等)。

Or is my best bet to just validate this on the frontend?还是我最好的选择只是在前端验证这一点?

Thanks.谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM