Guest User

Untitled

a guest
Feb 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import { check, validationResult } from 'express-validator/check';
  2.  
  3. const validatorSignup = [
  4. check('user_name').exists().isLength({ min: 4, max: 20 }),
  5. ....
  6. ];
  7.  
  8. router.post('/signup', (req, res) => {
  9. try {
  10. upload(req, res, validatorSignup, (err) => {
  11. console.log(req.body)
  12. const errors = validationResult(req.body);
  13. if (!errors.isEmpty()) {
  14. return res.status(422).json({
  15. err: errors.array()
  16. });
  17. }
  18. ....
  19. } catch (err) {
  20. return res.status(500).json({
  21. err: err
  22. });
  23. }
  24. });
  25.  
  26. onFinished(req, function () { next(err) })
  27. ^
  28. TypeError: next is not a function
  29.  
  30. router.post('/signup', (req, res) => {
  31. try {
  32. upload(req, res, (err) => {
  33. console.log(req.body)
  34. const errors = validationResult(req.body);
  35. if (!errors.isEmpty()) {
  36. return res.status(422).json({
  37. err: errors.array()
  38. });
  39. }
  40. ....
  41. } catch (err) {
  42. return res.status(500).json({
  43. err: err
  44. });
  45. }
  46. }, validatorSignup);
Add Comment
Please, Sign In to add comment