Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { check, validationResult } from 'express-validator/check';
- const validatorSignup = [
- check('user_name').exists().isLength({ min: 4, max: 20 }),
- ....
- ];
- router.post('/signup', (req, res) => {
- try {
- upload(req, res, validatorSignup, (err) => {
- console.log(req.body)
- const errors = validationResult(req.body);
- if (!errors.isEmpty()) {
- return res.status(422).json({
- err: errors.array()
- });
- }
- ....
- } catch (err) {
- return res.status(500).json({
- err: err
- });
- }
- });
- onFinished(req, function () { next(err) })
- ^
- TypeError: next is not a function
- router.post('/signup', (req, res) => {
- try {
- upload(req, res, (err) => {
- console.log(req.body)
- const errors = validationResult(req.body);
- if (!errors.isEmpty()) {
- return res.status(422).json({
- err: errors.array()
- });
- }
- ....
- } catch (err) {
- return res.status(500).json({
- err: err
- });
- }
- }, validatorSignup);
Add Comment
Please, Sign In to add comment