title: how to resolve data and hash error in node js bcrypt
body: <blockquote>
    <p>Error: data and hash arguments required</p>
  </blockquote>
  
  <p>i am doing simple, login signup and forgot password in node js using 
  bcrypt hash</p>
  
  <p>code : for login</p>
  
  <pre><code>app.post('/login', (req, res) =&gt; {
    console.log('login');
    let {email, password} = req.body;
      User.updateOne({email: email}, ' email password', (err, userData) =&gt; {
          if (!err) {
              let passwordCheck = bcrypt.compareSync(password, userData.password);
              if (passwordCheck) { 
              console.log('login2');
                  req.session.user = {
                    email: userData.email,
                    id: userData._id
                  }; 
                  req.session.user.expires = new Date(Date.now() + 3 * 24 * 3600 * 1000);
                  res.status(200).send('You are logged in, Welcome!');
              } else {
                res.status(401).send('incorrect password');
                console.log('login3');
              }
          } else {
            res.status(401).send('invalid login credentials');
            console.log('login4');
          }
      });
  });
  </code></pre>
  
  <p>code for signUp :</p>
  
  <pre><code>app.post('/signup', (req, res) =&gt; {
    let {email, password} = req.body; 
  
      let userData = {password: bcrypt.hashSync(password, 5, null), email };
      console.log('out save');
  
      let newUser = new User(userData);
  
       newUser.save().then(error =&gt; {
          if (!error) {
          console.log('in save');
              return res.status(200).json('signup successful');
          } else { 
              if (error.code ===  11000) { 
                  return res.status(409).send('user already exist!');
              } else {
                  console.log(JSON.stringigy(error, null, 2)); 
                  return res.status(500).send('error signing up user');
              }
          }
      });
  });
  </code></pre>
  
  <p>i have tried console logging few lines and turned out that the code doesn't go into signup </p>
  
  <pre><code>newUser.save();
  </code></pre>
  
  <p>tell me where i'm going wrong</p>