D
D
Dubolom Unicellular2020-07-10 14:12:04
Express.js
Dubolom Unicellular, 2020-07-10 14:12:04

What kind of array is passed to Express'a post request?

What does this array do in a post request from a router?

router.post(
  "/register",
  [
    check("email", "Некорректный email").isEmail(),
    check("password", "Минимальная длина пароля 6 символов").isLength({ min: 6 })
  ],
  () => { ... }

(Just code example)

Why this array? I did not find this parameter in the docks, it only talked about the path and callback parameters.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FabiBoom, 2020-07-10
@duboloms

After the first argument comes a sequence of middlewares (any number of them). You first have an array of middlewares, and then a regular middleware function.
This is described in the doc:
5f085274dfeb1738787333.png

H
hzzzzl, 2020-07-10
@hzzzzl

well, everyone has already answered, and this is express-validator
https://express-validator.github.io/docs/validatio...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question