'Err:data and salt arguments required

connectde with datadase (mongodatabase)
and chik if email == new email!
and used bcrypt to do securty password.

exports.createNewUser = (username, email, password) => {
  return new Promise((resolve, reject) => {
    mongoose
      .connect(DB_Url)
      // email no rebeted
      .then(() => {
        return User.findOne({ email: email });
      })

      .then((user) => {
        if (user) {
          mongoose.disconnect();
          reject("email is used");
        } else {
         

return bcrypt.hash(this.password, 10);

        }
      })

securty from pass

      .then((hashedPassword) => {
        let user = new User({
          username: username,
          email: email,
          password: hashedPassword,
        });
        return user.save();
      })
      .then(() => {
        mongoose.disconnect();
        resolve("user created");
      })
      .catch((err) => {
        mongoose.disconnect();
        reject(err);
      });
  });
};


  


Solution 1:[1]

It seems that this.password doesn't have a value. Make sure it has a value assigned, otherwise Bcrypt will fail.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 crazy_enter