Ensure beforeSave hook response is object before stripping (#1969)

This commit is contained in:
Tyler Brock
2016-06-01 12:01:35 -07:00
committed by Drew
parent 38f02af511
commit abeecad907

View File

@@ -202,11 +202,14 @@ function wrapToHTTPRequest(hook, key) {
err = body.error;
}
}
if (err) {
return res.error(err);
} else if (hook.triggerName === 'beforeSave') {
delete result.createdAt;
delete result.updatedAt;
if (typeof result === 'object') {
delete result.createdAt;
delete result.updatedAt;
}
return res.success({object: result});
} else {
return res.success(result);