Skip to content

Commit

Permalink
Fix wrong method hooks context (#1307)
Browse files Browse the repository at this point in the history
* Fix wrong method hooks context

Fix passing the wrong context into before and after method hooks

* Using 'this' and arrow functions instead of 'self'
  • Loading branch information
priezz authored and jshimko committed Aug 20, 2016
1 parent 7e49a09 commit fc17fb7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/api/method-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ MethodHooks._initializeHook = function (mapping, methodName, hookFunction) {
let beforeResult;
// Call the before hooks
let beforeHooks = MethodHooks._beforeHooks[methodName];
_.each(beforeHooks, function (beforeHook, hooksProcessed) {
_.each(beforeHooks, (beforeHook, hooksProcessed) => {
beforeResult = beforeHook.call(this, {
result: undefined,
error: undefined,
Expand Down Expand Up @@ -117,7 +117,7 @@ MethodHooks._initializeHook = function (mapping, methodName, hookFunction) {

// Call after hooks, providing the result and the original arguments
let afterHooks = MethodHooks._afterHooks[methodName];
_.each(afterHooks, function (afterHook, hooksProcessed) {
_.each(afterHooks, (afterHook, hooksProcessed) => {
let hookResult = afterHook.call(this, {
result: methodResult,
error: methodError,
Expand Down

0 comments on commit fc17fb7

Please sign in to comment.