I'm unable to find answers to this, although it should be a relatively common issue. All other questions seem to relate to simply adding variables to an empty closure.
I have a callback which takes two arguments; err and docs, which I still need, but also want to add an additional argument of `data.
db.findOne().exec(function (err, docs) {
// err is defined
// docs is defined
});
I need to pass data along with it, so assumed I could do this:
db.findOne().exec(function (err, docs, data) {
// err is defined
// docs is defined
}(data));
This doesn't work. So, I tried the following:
db.findOne().exec(function (err, docs, data) {
// err is null
// docs is null
}(null, null, data));
This killed the original variables err and docs as well.
So, how would I go about doing this?
function (err, docs, data) {should returninner functionas a handler of.exec