Skip to content

Instantly share code, notes, and snippets.

@nategraves
Last active August 29, 2015 14:00
Show Gist options
  • Save nategraves/88d250541d141f4e120b to your computer and use it in GitHub Desktop.
Save nategraves/88d250541d141f4e120b to your computer and use it in GitHub Desktop.
var _boards = null;
var setBoards = function(boards) {
_boards = boards;
}
var getBoards = function() {
Trello.get(
'/members/me',
{boards:"open",organizations:"all"},
function(data) {
setBoards(data.boards);
},
function(xhr){
if (xhr.status == 401) {
Trello.deauthorize();
Trello.authorize();
} else {
$("#view").html("<h1>Connection to Trello API is broken, Please <a href='javascript:reload();'>Reload</a></h1>");
}
}
);
};
@danielmcgrath
Copy link

function getBoards(callback) {
  Trello.get(
    '/members/me',
    {boards:"open",organizations:"all"},
    function(data) { callback(data.boards); },
    function(xhr){
      if (xhr.status == 401) {
        Trello.deauthorize();
        Trello.authorize();
      } else {
        $("#view").html("<h1>Connection to Trello API is broken, Please <a href='javascript:reload();'>Reload</a></h1>");
      }
    }
  );
}

getBoards(function(boards) {
  // Now you have the boards, do whatever you want with them
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment