【发布时间】:2020-08-09 05:59:57
【问题描述】:
我想不通。为什么是我的要求:
localhost:3000/api/customers/search?q=glenn
前往:
// Retrieve a single Customer with customerId
router.get("/:customerId", customers.findOne);
什么时候到这里???
// Search for a customer.
router.get("/search/:q", customers.search)
customer.routes.js
module.exports = app => {
const customers = require("../controllers/customer.controller");
const router = require("express").Router();
// Create a new Customer
router.post("/", customers.create);
// Retrieve all Customers
router.get("/", customers.findAll);
// Search for a customer.
router.get("/search/:q", customers.search)
// Retrieve a single Customer with customerId
router.get("/:customerId", customers.findOne);
// Update a Customer with customerId
router.put("/:customerId", customers.update);
// Delete a Customer with customerId
router.delete("/:customerId", customers.delete);
// Create a new Customer
router.delete("/", customers.deleteAll);
app.use("/api/customers", router)
};
Morgan + Sequelize 日志:
正在执行(默认):SELECT
id,name,active,createdAt,updatedAtFROMcustomersAScustomerWHEREcustomer.id= '搜索'; ::1 - - [25/Apr/2020:16:41:06 +0000] “获取 /api/customers/search?q=glenn HTTP/1.1" 200 0 "-" “邮递员运行时/7.24.1”
【问题讨论】:
-
从日志中,它正在搜索。检查您的搜索方法。那不是 findone 电话。
标签: javascript node.js express