Resolving 500 error when deleting an action.

This commit is contained in:
David Jay
2016-11-15 14:24:38 -05:00
parent 44292a81ad
commit fbf27a9d75
3 changed files with 8 additions and 7 deletions
@@ -248,7 +248,8 @@ export function deleteAction (item_id, action_type, user_id, item_type) {
return () => {
const action = {
action_type,
user_id
user_id,
item_id
};
return fetch(`/api/v1/${item_type}/${item_id}/actions`, getInit('DELETE', action))
+4 -4
View File
@@ -194,12 +194,12 @@ CommentSchema.statics.removeById = function(id) {
* @param {String} action_type the type of the action to be removed
* @param {String} user_id the id of the user performing the action
*/
CommentSchema.statics.removeAction = function(id, user_id, action_type) {
CommentSchema.statics.removeAction = function(item_id, user_id, action_type) {
return Action.remove({
action_type: action_type,
action_type,
item_type: 'comment',
item_id: id,
user_id: user_id
item_id,
user_id
});
};
+2 -2
View File
@@ -135,9 +135,9 @@ router.delete('/:comment_id', (req, res, next) => {
router.delete('/:comment_id/actions', (req, res, next) => {
Comment
.removeAction(req.params.comment_id, req.body.user_id, req.body.action_type)
.removeAction(req.params.item_id, req.body.user_id, req.body.action_type)
.then(() => {
res.status(201).sent({});
res.status(201).send({});
})
.catch(error => {
next(error);