Я не могу понять это. Почему это мой запрос:
localhost:3000/api/customers/search?q=glenn
Идет:
// Retrieve a single Customer with customerId
router.get("/:customerId", customers.findOne);
, когда он должен go сюда ???
// 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
, email
, name
, active
, createdAt
, updatedAt
ОТ customers
КАК customer
ГДЕ customer
. id
= 'search'; :: 1 - - [25 / Apr / 2020: 16: 41: 06 +0000] "GET / api / Customers / search? Q = glenn HTTP / 1.1" 200 0 "-" "PostmanRuntime / 7.24.1"