Skip to content

Instantly share code, notes, and snippets.

@paulobunga
Created March 17, 2022 09:07
Show Gist options
  • Save paulobunga/1fd249575a2a355ad387112e85fa956d to your computer and use it in GitHub Desktop.
Save paulobunga/1fd249575a2a355ad387112e85fa956d to your computer and use it in GitHub Desktop.
Insert new employee into the database
app.post("employees", function (req, res) {
let newEmployee = { ...req.body };
db.query("INSERT INTO employees SET ?", newEmployee, (error, result) => {
if (error) {
return res.status(500).json({ status: "ERROR", error });
}
return res.json({ status: "SUCCESS" });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment