I am not able to execute post request in postman.
It gives a internal server error. Here I am using localhost with phpmyadmin.
Here is my code for POST data using postman.
app.post('/login', (req, res) => {
const username = req.body.username
const password = req.body.password
const sql = "INSERT INTO `dataa`(`username`, `password`) VALUES (?, ?)"
db.query(sql, [username, password], (err, rows, fields) => {
if(!err)
res.send(rows);
else {
console.log(err);
}
})
})
2
Answers
Table name shouldn’t be in quotation
Use like this
const sql = “INSERT INTO dataa(‘username’,’password’) VALUES (?, ?)”