diff --git a/index.js b/index.js index 167419d..fc723eb 100644 --- a/index.js +++ b/index.js @@ -467,12 +467,12 @@ class API { let middleware = []; // Add func args as middleware - for (let arg in args) { - if (typeof args[arg] === 'function') { - if (args[arg].length === 3) { - middleware.push(args[arg]); - } else if (args[arg].length === 4) { - this._errors.push(args[arg]); + for (let arg of args) { + if (typeof arg === 'function') { + if (arg.length === 3) { + middleware.push(arg); + } else if (arg.length === 4) { + this._errors.push(arg); } else { throw new ConfigurationError( 'Middleware must have 3 or 4 parameters'