0

我在创建高阶函数来修剪空白时遇到问题

const { trim } = require('validator')

const whiteSpace2 = () => (req:any) => {
  Object.keys(req.body).forEach((key) => {
    if (typeof req.body[key] === 'string') req.body[key] = trim(req.body[key])
  })
}

fastify.post('/login', (req:any, res:any) => {
  whiteSpace2()
  console.log(req.body)
  return res.code(403).send('error')
})

该函数永远不会被执行

4

0 回答 0