Given the following node.js module, how would I call the functions in the array orderedListOfFunctions passing each one the response variable?
var async = require("async");
var one = require("./one.js");
var two = require("./two.js");
module.exports = function (options) {
var orderedListOfFunctions = [
one,
two
];
return function (request, response, next) {
// This is where I'm a bit confused...
async.series(orderedListOfFunctions, function (error, returns) {
console.log(returns);
next();
});
};
You can use
bindto do this like so:The
bindcall prependsresponseto the list of parameters provided to theoneandtwofunctions when called byasync.series.Note that I also moved the results and
next()handling inside the callback as that’s likely what you want.