Javascript 快速验证程序返回值:未定义的消息:';无效值';

Javascript 快速验证程序返回值:未定义的消息:';无效值';,javascript,express,request,postman,express-validator,Javascript,Express,Request,Postman,Express Validator,路线 日志控制器 const express = require('express'); const { check } = require('express-validator'); const logControllers = require('../controllers/log-controllers'); const router = express.Router(); router.post('/', [ check('title') .

路线

日志控制器

const express = require('express');
const { check } = require('express-validator');

const logControllers = require('../controllers/log-controllers');


const router = express.Router();

router.post('/',
    [
      check('title')
         .not()
         .isEmpty()
    ],
    logControllers.createLogEntry
);
当我移除验证器时,POST请求起作用,但验证器Nodemon返回:

const uuid = require('uuid/v4');
const { validationResult } = require('express-validator');
const HttpError = require('../models/http-error');

let DUMMY_LOGENTRIES = [
    {
        id: "j1",
        title: "king"}]

const createLogEntry = (req, res, next) => {
    const errors = validationResult(req);
    if (!errors.isEmpty()) {
        console.log(errors);
        throw new HttpError('Invalid inputs passed, please check your data.', 422);
    }
    const { title } = req.body;
    const createdLogEntry =
    //new logEntry(
    {
        id: uuid(), title  
    };
    DUMMY_LOGENTRIES.push(createdLogEntry);
    res.status(201).json({ logEntry: createdLogEntry });
};

额外问题:如果没有验证程序,返回的响应只是uuid。。。不是标题,我不明白为什么,因为我要求完整的createdLogEntry,它应该返回标题和uuid。想法?

没有发现验证器缺少什么,但我确实发现我在Postman中返回的是文本而不是JSON。只要重写所有内容,它就成功了。我猜是语法问题

  formatter: [Function: formatter],
  errors: [
    {
      value: undefined,
      msg: 'Invalid value',
      param: 'title',
      location: 'body'
    },