I'm starting with nodejs, but whenever I try to send (email and password) to the API via POST, the typed values are returned as NULL.
router.post("/users", function(req, res){
console.log(req.body)
let query = "INSERT INTO ??(??,??) VALUES (?,?)";
let table = ["user_login","user_email","user_password", req.body.email, md5(req.body.password)];
query = mysql.format(query, table);
console.log(query)
connection.query(query, function(err, rows){
if(err){
res.json({"Error": true, "Message": "Erro ao executar a query do MYSQL"})
}else{
res.json({"Error" : false, "Message": "Usuario adicionado!"});
}
})
});
REST.prototype.configureExpress = function(connection){
let self = this;
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
let router = express.Router();
app.use('/api', router);
let rest_router = new rest(router, connection, md5);
self.startServer();
}