TypeError: req.checkBody is not a function
With express-validator
6 you will have to do the following:
import
var router = express.Router();
var { body, validationResult} = require('express-validator');
validation
body('username').isEmail()
body('password').isLength({ min: 5 })
errors
const errors = validationResult(req);
You need to install express-validator
using below command
npm install express-validator
then add
var expressValidator = require('express-validator');
api.use(expressValidator())
immediately after
var api = express.Router();
See TypeError: req.checkBody is not a function including bodyparser and expressvalidator module for more details