I have this function to get some data from the internet:
function GetData(callback) {
var data = [
["username", "password", "email"]//Header values
];
doc.getInfo(function (err, sheet_info) { //the doc is an google spreadsheet object
sheet_info.worksheets[0].getRows(function(err, rows) {
_.forEach(rows, function(row) {
data.push([row.name, row.password, row.email]);
} );
});
});
callback(data);
}
But when i try to use this function:
GetData(function (data) {
console.log(data) //Has only first initial values ["username", "password", "email"]
});
Any idea what might be the problem ?