Answer the question
In order to leave comments, you need to log in
How to pass data to a function in async using async.auto/async.apply?
Tell me if it's possible to do the following.
There is a set of functions, some of them must be executed in parallel, some sequentially, so I had to turn to async.auto. But ran into a problem
var set = {};
async.auto({
one: async.apply(getDocument, set),
two: ['one', async.apply(otherDataDocument, set)]
}, function(){})
function getDocument(set, callback) {
callback(null, data);
}
function otherDataDocument(set, callback) {
// суда необходимо передать данные из функции getDocument
}
Answer the question
In order to leave comments, you need to log in
Hold
var async = require('async');
async.auto({
one: getDocument,
two: ['one', otherDataDocument]
}, function () {
})
function getDocument(callback) {
var data = "it works";
callback(null, data);
}
function otherDataDocument(callback, result) {
console.log(result);
callback(null);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question