diff options
author | Matthew Strapp <msattr@gmail.com> | 2021-04-30 21:35:25 -0500 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2021-04-30 21:35:25 -0500 |
commit | 2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9 (patch) | |
tree | a397c151b8378e179609fdde2d59a8c037091c70 /csci4131/hw7/api | |
parent | Rearrange, add old contacts page because other is "copyrighted" (diff) | |
download | homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar.gz homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar.bz2 homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar.lz homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar.xz homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.tar.zst homework-2b37edf1e2f0b4a5e931b94de422e5bfc1ca1fa9.zip |
Finish HW
Diffstat (limited to '')
-rw-r--r-- | csci4131/hw7/api/utilities.js | 22 |
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;
|