Skip to content

Commit

Permalink
Fixed bug with asynch SHIT
Browse files Browse the repository at this point in the history
  • Loading branch information
lmatteis committed Dec 18, 2011
1 parent 936a7b7 commit fb72286
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ trello.api = function(apiCall, callback) {
trello.get = function(org, callback) {
trello.api("/" + org, function(data) {
var len = data.boards.length;
var done = 0;
var ret = [];
data.boards.forEach(function(i, idx) {
var id = i._id;
var ret = [];
trello.api("/board/" + id + "/current", function(data) {
done++;
ret.push(data.boards[0]);
if(idx === (len-1)) { // last
if(done === len) { // last
callback(ret);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var tests = {
},
getEssentialStructure: function() {
trello.get("grinfo", function(data) {
console.log(data[0]);
console.log(data);
});
}
};
Expand Down

0 comments on commit fb72286

Please sign in to comment.