我想获得某个特雷洛列表中的头牌,然后将其名称发布到我的不和谐频道中,但是,我不确定如何获得第一张牌。
yangx456 回答:如何获得特雷洛名单的头牌
我建议您看看Trello Rest API documentation
满足您需求的更精确的页面:
Trello在这些页面上提供了Node.js示例。
经过一番研究,这就是我设法获取在某块板上找到的名字第一张卡片的原因:
// Getting all lists from a certain board.
fetch(`https://api.trello.com/1/boards/{id}/lists?key={apiKey}&token={token}`,{
method: 'GET',}).then(response => {
let lists = JSON.parse(response.body);
// Searching for a list with a certain name and store it's id.
let certainListId = lists.find(list => list.name === "listName").id;
// Use the stored id in certainListId to get all cards of the list.
fetch(`https://api.trello.com/1/lists/${certainListId}/cards`,{
method: 'GET'
}).then(response => {
let certainListCards = JSON.parse(response.body);
// Cards in the array is in top to bottom order. So top one is the very first.
let firstCard = certainListCards[0];
// Send with the bot the name of the first (top) card thanks to firstCard.name property.
}).catch(err => console.error(err));
}).catch(err => console.error(err));