app.post('', (req, res) => {
pool.getConnection((err, connection) => {
if (err) throw err
console.log('connected as id' + connection.threadID)
const params = req.body;
connection.query('INSERT INTO beers SET ?', [params], (err, rows) => {
connection.release()
if (!err) {
res.send('Successfully added record of name' + params.name)
} else {
console.log(err)
}
})
console.log(req.body)
})
})
I'm not sure what kind of library you're using to communicate with the DB, but I reckon, it should look more like
connection.query('INSERT INTO beers(someColumn, someOtherColumn) VALUES (?,?)', [params.valueOfSomeColumn, params.valueOfSomeOtherColumn],...blabla the rest)
? characters with the value from an array