This code below returns the input password as null, but all other inputs are fine. I don’t know what to do, if anyone can help please do.
I am using bcrypt with knex for psql.
app.post("/register", (req, res) => {
const { email, name, password } = req.body;
let salt = bcrypt.genSaltSync(10);
let hash = bcrypt.hashSync(password, salt);
knex
.transaction((trx) => {
trx
.insert({
hash: hash,
email: email,
})
.into("login")
.returning("email")
.then((loginEmail) => {
return trx("users")
.returning("*")
.insert({
email: loginEmail[0].email,
name: name,
joined: new Date(),
})
.then((user) => {
res.json(user[0]);
});
})
.then(trx.commit)
.catch(trx.rollback);
})
.catch((err) => res.status(400).json("E-mail is already in use"));
});