I am trying to have a simple post function which uses bcrypt on the password passed, then stores the data in the database, however when I call the post request in postman I am getting an error. I add a console output to see what the body was showing up as, and it is just showing an empty object. Does anyone know what could be causing this? Below is my server code:
app.post('/createUser/', function(req, res) {
console.log("below is the req body");
console.log(req.body);
var pass = bcrypt.hashSync(req.body.password, salt);
var createPromise = interact.createUser(req.body.username,
pass,);
//did promise
createPromise.then(function(createResponse) {
if (createResponse.length > 0){
//this means that there was a user with that username in the db
res.json("yes");
}
else {
// otherwise, there wasn't anything in the database with this id
res.json("no");
}
}).catch(function(err) {
console.log(err);
console.log(req.body);
res.status(500).json(err);
});
});