-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeletenoti.js
More file actions
24 lines (19 loc) · 760 Bytes
/
deletenoti.js
File metadata and controls
24 lines (19 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const router = express.Router();
const bodyParser = require('body-parser');
const db = require('./db.js');
router.delete('/', (req, res) => {
const {user_id, noti_id} = req.body;
const sql = 'DELETE FROM notifications WHERE user_id = ? AND noti_id = ?';
const values = [user_id, noti_id];
db.query(sql, values, (error, results) => {
if (error) {
console.error('Error executing MySQL query: ',error);
res.status(500).send('Internal server error');
return;
}
console.log('${user_id} Noti ${noti_id} deleted successfully');
res.status(200).send('${user_id} Noti ${noti_id} deleted successfully');
});
});
module.exports = router;