Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // Add a new test-resource-a
  2. app.post('/test-resource-a', (request, response) => {
  3. pool.query('INSERT INTO my_table SET ?', request.body, (error, result) => {
  4. if (error) {
  5. next(err);
  6. }
  7. response.status(201).send(`test-resource-a added with id: ${result.insertId}`);
  8. });
  9. });
  10.  
  11. //An error handling middleware
  12. app.use(function (err, req, res, next) {
  13. res.status(500);
  14. res.send("Oops, something went wrong.")
  15. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement