title: UnhandledPromiseRejectionWarning: Error: WHERE parameter "username" has invalid "undefined" value in postman
body: <p>Currently working on a backend in nodejs for a login page. I'm following this tutorial <a href="https://bezkoder.com/node-js-jwt-authentication-mysql/" rel="nofollow noreferrer">https://bezkoder.com/node-js-jwt-authentication-mysql/</a></p>
  <p>When I try to go to http://localhost:8080/api/auth/signup in postman I get these errors in my server:</p>
  <p><a href="https://i.stack.imgur.com/dD7am.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dD7am.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/mB9Vo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mB9Vo.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/qTgFk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qTgFk.png" alt="enter image description here" /></a></p>
  <p>set appropriate Header: Content-Type: application/json and I also set body from test to json in postman</p>
  <p>I believe it is coming from this snippet of code, but the rest of the code is in the github link if you need more code.</p>
  <p>Github link: <a href="https://github.com/bezkoder/node-js-jwt-auth" rel="nofollow noreferrer">https://github.com/bezkoder/node-js-jwt-auth</a></p>
  <p>In verifySignup.js:</p>
  <pre><code> const db = require(&quot;../models&quot;);
   const ROLES = db.ROLES;
   const User = db.user;
  
   checkDuplicateUsernameOrEmail = (req, res, next) =&gt; {
   // Username
  User.findOne({
   where: {
     username: req.body.username
    }
    }).then(user =&gt; {
    if (user) {
     res.status(400).send({
      message: &quot;Failed! Username is already in use!&quot;
     });
     return;
    }
  
   // Email
   User.findOne({
     where: {
      email: req.body.email
     }
    }).then(user =&gt; {
     if (user) {
      res.status(400).send({
         message: &quot;Failed! Email is already in use!&quot;
       });
      return;
     }
  
     next();
   });
  });
  };
  </code></pre>
  <p>In auth-routes.js my request to register:</p>
  <pre><code> app.post(
   '/api/auth/signup', 
   [
     verifySignUp.checkDuplicateUsernameOrEmail,
      verifySignUp.checkRolesExisted
    ],
   controller.signup
  );
  </code></pre>
  <p>Server.js (all code):</p>
  <pre><code>const express = require(&quot;express&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  const cors = require(&quot;cors&quot;);
  
  const app = express();
  
   var corsOptions = {
   origin: &quot;http://localhost:8081&quot;
  };
  
  
  
  app.use(cors(corsOptions));
  
  // parse requests of content-type - application/json
  app.use(bodyParser.json());
  
  // parse requests of content-type - application/x-www-form-urlencoded
  app.use(bodyParser.urlencoded({ extended: true }));
  
  // routes
  require('./app/routes/auth.routes')(app);
  require('./app/routes/user.routes')(app);
  
  // database
  const db = require(&quot;./app/models&quot;);
  const Role = db.role;
  
  //db.sequelize.sync();
  // force: true will drop the table if it already exists
  db.sequelize.sync({force: true}).then(() =&gt; {
  console.log('Drop and Resync Database with { force: true }');
  initial();
   });
  
  // simple route
  app.get(&quot;/&quot;, (req, res) =&gt; {
  res.json({ message: &quot;Welcome to bezkoder application.&quot; });
  });
  
  
  
  // set port, listen for requests
  const PORT = process.env.PORT || 8080;
  app.listen(PORT, () =&gt; {
   console.log(`Server is running on port ${PORT}.`);
  });
  
   function initial() {
   Role.create({
    id: 1,
    name: &quot;user&quot;
   });
  
   Role.create({
    id: 2,
    name: &quot;moderator&quot;
   });
  
   Role.create({
    id: 3,
    name: &quot;admin&quot;
   });
   }
  </code></pre>