Skip to content

Instantly share code, notes, and snippets.

@ThomasTheFourth
Created September 18, 2020 14:39
Show Gist options
  • Save ThomasTheFourth/4b41e1c3a25194e73ee49c82dad5b6e4 to your computer and use it in GitHub Desktop.
Save ThomasTheFourth/4b41e1c3a25194e73ee49c82dad5b6e4 to your computer and use it in GitHub Desktop.
es6 to retrieve a random card from any list on a Trello board
let key='';
let token='';
let boardid='';
fetch('https://api.trello.com/1/boards/' + boardid + '/lists?key=' + key + '&token=' + token + '')
.then(response => response.json())
.then(data => {
randomList = data[Math.floor(Math.random()*data.length)];
console.log(randomList);
fetch('https://api.trello.com/1/lists/' + randomList.id + '/cards?key=' + key + '&token=' + token + '')
.then(response => response.json())
.then(data => {
console.log(data[Math.floor(Math.random()*data.length)].name);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment