Das sollte es sein,
app.post('/data', function(req, res){
var username=req.body.name;
connection.query("INSERT INTO `names` (name) VALUES (?)", username.toString(), function(err, result){
if(err) throw err;
console.log("1 record inserted");
});
res.send(username);
});