Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add a new test-resource-a
- app.post('/test-resource-a', (request, response) => {
- pool.query('INSERT INTO my_table SET ?', request.body, (error, result) => {
- if (error) {
- next(err);
- }
- response.status(201).send(`test-resource-a added with id: ${result.insertId}`);
- });
- });
- //An error handling middleware
- app.use(function (err, req, res, next) {
- res.status(500);
- res.send("Oops, something went wrong.")
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement