From 2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Fri, 30 Apr 2021 21:35:25 -0500 Subject: Finish HW --- csci4131/hw7/api/utilities.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'csci4131/hw7/api') 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; -- cgit v1.2.3