title: Error: Route.post() requires a callback function but got a [object Promise]
body: <p>I am creating a REST API with express, folowing are my architecture,a router is calling a controller.but I got this error, please help me</p>
  <pre><code>Error: Route.post() requires a callback function but got a [object Promise]
  </code></pre>
  <p>/////// EmailLogin.js middleware Handler</p>
  <pre><code>const { validationResult } = require('express-validator');
  
  
     let wrapRoute = async (req, res, next) =&gt; {
    try {
        // run controllers logic
        await fn(req, res, next)
    } catch (e) {
        // if an exception is raised, do not send any response
        // just continue performing the middleware chain
        next(e)
    }
  }
  
  
  
  
  const EmailLogin = wrapRoute(async (req, res) =&gt; {
  
      const errors =  validationResult(req);
      if (!errors.isEmpty()) {
      return res.status(422).json({ errors: errors.array() });
  
      } else {
  
    var gtoken = req.body.gtoken;
    var gSecretKey = env.secret_key;
     
      if (!gtoken) throw new Error('no token')
  
      const captchaURL = `https://www.google.com/recaptcha/api/siteverify?secret=${gSecretKey}&amp;response=${gtoken}`
   
      await  axios({
        url: captchaURL,
        method: 'POST',
        headers: {ContentType: 'application/x-www-form-urlencoded'},
    
      }).then(response =&gt; {
      
        const gVerifyData = response.data
        if (gVerifyData.success === true) {
         Users.findOne({'email': req.body.email}).select('+hashPassword +status').exec(function (err, user)  {
  
            if(err){
                return res.status(500).send({err});
              } else if (user) {
             
                validPassword = bcrypt.compareSync(req.body.password, user.hashPassword);
  
                if (!validPassword){
  
                  return res.send(&quot;wrong-info&quot;);
               
                } else  if (validPassword &amp;&amp; user.status == &quot;active&quot;)  {
            
                  token = jwt.sign({ id: user._id }, env.jwtsecret, 
                  { expiresIn: &quot;168h&quot; });
                  res.status(200).send({ token: token, user });
  
                  }
              }  else {
  
                return res.send(&quot;wrong-info&quot;);
              
              }
              }
              )
            }else {
              return  res.status(500).send('bot');
            }
      }).catch(error =&gt;  {
            console.log(error);
          
          });
        }
      });
  
  
  
  
  
      function errorHandler (err, req, res, next) {
        console.log(err);
        // If err has no specified error code, set error code to 'Internal Server Error (500)'
        if (!err.statusCode) {
            err.statusCode = 500;
        } 
        
        res.status(err.statusCode).json({
            status: false,
            error: err.message
        });
   
    };
  
  module.exports = {EmailLogin};
  </code></pre>
  <p>I'm trying to call it in my router, like this:</p>
  <p>/////// Router.js</p>
  <pre><code>const express = require('express');
  const router  = express.Router();
  const { check } = require('express-validator');
  
  const EmailLoginController = require('../controllers/EmailLogin');
  
  
  var emailLoginValidation = [
      check('email').notEmpty().trim().escape().isEmail(),
      check('password').notEmpty().isLength({ min: 7 }).withMessage('password is invalid'),
    ];
  
  
  
  router.post('/email-login', emailLoginValidation, EmailLoginController.EmailLogin);
  
  
  module.exports = router;
  </code></pre>
  <p>/////// App.js</p>
  <pre><code>var express = require(&quot;express&quot;);
  var app = express();
  
  
  const Router = require('./routes/Router');
  app.use('/', Router); 
  
  
  app.listen(3000, function() {
    console.log('listening on 3000');
    
  });
  </code></pre>
  <p>What could I do ? is it possible to get a Promise Result in the Router as a  Handler?</p>