In node.js I need to collect some data across multiple callbacks and store them in one object. I tried the following code, but the collected data is not saved in the initialized variable. Can you pls help what I'm doing wrong?
My code:
for (var x in data) {
var status = {items: []};
for (var y in x) {
do_something(y, function (err, res) {
again_do_something(res, function(err, result) {
status.items.push({key: result});
});
});
}
console.log(status); //Here I got only {items: []}
}