aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw7/api/utilities.js
diff options
context:
space:
mode:
Diffstat (limited to 'csci4131/hw7/api/utilities.js')
-rw-r--r--csci4131/hw7/api/utilities.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/csci4131/hw7/api/utilities.js b/csci4131/hw7/api/utilities.js
index 65a087f..12e06aa 100644
--- a/csci4131/hw7/api/utilities.js
+++ b/csci4131/hw7/api/utilities.js
@@ -40,9 +40,25 @@ router.get('/logout', function(req, res) {
router.post('/addContact', function(req, res) {
var contact = req.body;
- db.addContact(contact).then(function() {
- res.redirect('/contacts');
- });
+ db.addContact(contact).then(function(r) {
+ res.send({flag: r});
+ }).catch(function() {
+
+ })
});
+router.post('/updateContact', function(req, res) {
+ var edit = req.body;
+ db.editContact(edit).then(function(f) {
+ res.send({flag:f});
+ });
+})
+
+router.post('/deleteContact', function(req, res) {
+ var contact = req.body.name;
+ db.deleteContact(contact).then(function(r) {
+ res.send({flag: r});
+ })
+})
+
module.exports = router;