I need to request data from two web servers. The tasks are independent; therefore, I am using aync.parallel. Now I am only writing \'abc\', \'xyz\', and \'Done\' to the body
If you want to be absolutely certain in the order in which the results are printed, you should pass your data (abc\n
and xyz\n
) through the callbacks (first parameter is the error) and handle/write them in the final async.parallel
callback's results
argument.
async.parallel({
one: function(callback) {
callback(null, 'abc\n');
},
two: function(callback) {
callback(null, 'xyz\n');
}
}, function(err, results) {
// results now equals to: results.one: 'abc\n', results.two: 'xyz\n'
});