Skip to content

Instantly share code, notes, and snippets.

@mpcowan
Last active May 19, 2022 17:37
Show Gist options
  • Save mpcowan/2b3068fbaff7033ad1cfebaad5d35c8e to your computer and use it in GitHub Desktop.
Save mpcowan/2b3068fbaff7033ad1cfebaad5d35c8e to your computer and use it in GitHub Desktop.
// The script at https://p.trellocdn.com/card.min.js
// must already be loaded at this point
const idCard = 'CjBy4OpQ';
const api = 'https://api.trello.com/1/card';
const opts = {
fields: 'name,closed,cover,url,badges,labels',
customFields: true,
customFieldItems: true,
members: true,
stickers: true,
};
const qs = Object.keys(opts)
.map((param) => `${param}=${opts[param]}`)
.join('&');
const resp = await fetch(`${api}/${idCard}?${qs}`);
const cardData = await resp.json();
// create the card element
const cardEl = document.createElement('trello-card');
// pass in the data about the card
cardEl.card = cardData;
cardEl.labeltext = true;
cardEl.colorblind = true;
// insert our card element into the DOM
document.getElementById('card-container').appendChild(cardEl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment