错误:rout.get()需要一个回调函数,但得到了[对象未定义] - 搜索express
我正在尝试使用查询(express nodejs)来修复搜索功能,但是我收到了此错误消息...有什么想法我缺少什么?
谢谢!
路线:
const SearchController = require("../controllers/search");
route.get("/search/limit", SearchController.searchLimit);
搜索功能:
const Product = require("../models/Product");
const searchLimit = async (req, res) => {
try {
const { keywords } = req.query;
keywords = keywords.toLowerCase();
Product.findAll(
{ where: { keywords: { [Op.like]: "%" + term + "%" } } },
{ limit: 5 }
)
.then((output) => res.send("search result", { output }))
.catch((error) => console.log(error));
} catch (err) {
coneole.log(err);
return err;
}
};
module.export = { searchLimit };
错误消息:
Error: Route.get() requires a callback function but got a [object Undefined]
I'm trying to fix a search functionality with query (express nodeJS) but I get this error message... Any ideas what I'm missing?
Thanks!
the route:
const SearchController = require("../controllers/search");
route.get("/search/limit", SearchController.searchLimit);
the search function:
const Product = require("../models/Product");
const searchLimit = async (req, res) => {
try {
const { keywords } = req.query;
keywords = keywords.toLowerCase();
Product.findAll(
{ where: { keywords: { [Op.like]: "%" + term + "%" } } },
{ limit: 5 }
)
.then((output) => res.send("search result", { output }))
.catch((error) => console.log(error));
} catch (err) {
coneole.log(err);
return err;
}
};
module.export = { searchLimit };
the error message:
Error: Route.get() requires a callback function but got a [object Undefined]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论