Created
March 17, 2022 09:07
-
-
Save paulobunga/1fd249575a2a355ad387112e85fa956d to your computer and use it in GitHub Desktop.
Insert new employee into the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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