Skip to content

Commit

Permalink
Can now do a put request from my api
Browse files Browse the repository at this point in the history
  • Loading branch information
SSBinks committed Jan 20, 2017
1 parent 56c21a6 commit b439fc5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Binary file modified models/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ router.route('/assign/:due_date')
});
});

router.route('/assign/update/:assign_id')
.put(function(req, res) {
Assignment.findById(req.params.assign_id, function(err, assignment) {
if(err)
res.send(err);
console.log('the id ' + assignment);
let keys = Object.keys(req.body);
for(var i =0; i < keys.length; i++){

let key = keys[i];
console.log('the key is ' + key);
console.log('the second ' + req.body[key]);

assignment[key] = req.body[key];
}
assignment.save(function(err) {
if(err)
res.send(err);
res.json(assignment);
})
});
});

router.route('/assign/categories/:categories')
.get(function(req, res) {
AssignmentType.find({categories: req.params.categories}, function(err, type){
Expand Down

0 comments on commit b439fc5

Please sign in to comment.