Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Hello,
I am trying to make a post request with express-validator, but postman keeps hanging on “sending request…”.
here is my code ----->
const express = require('express');
const router = express.Router();
const { check, validationResult } = require('express-validator/check');
router.post(
'/',
[
check('name', 'Name is required').not().isEmpty(),
check('email', 'Please include email').isEmail,
check(
'password',
'Please enter a password with 6 or more characters'
).isLength({ min: 6 }),
],
(req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
res.send('OK');
}
);
module.exports = router;
What could be the issue?
Without express-validators postman does work normally and sends the request without delay.
Thanks!