简体   繁体   中英

How do I get certain info of the top card on a Trello list?

I'm hoping to get the name, label, and due date of the first few cards in one of the Trello lists on my board and sending it over Discord using my bot. How would I go about getting this info?

You will have to work with there API, and with a fetch library to make requests. They gave some example of how to use their API like this:

// This code sample uses the 'node-fetch' library:
// https://www.npmjs.com/package/node-fetch
const fetch = require('node-fetch');

fetch('https://api.trello.com/1/cards?key=0471642aefef5fa1fa76530ce1ba4c85&token=9eb76d9a9d02b8dd40c2f3e5df18556c831d4d1fadbe2c45f8310e6c93b5c548&idList=5abbe4b7ddc1b351ef961414', {
  method: 'POST'
})
  .then(response => {
    console.log(
      `Response: ${response.status} ${response.statusText}`
    );
    return response.text();
  })
  .then(text => console.log(text))
  .catch(err => console.error(err));

You have lot of option to deal with, and it's like php options ( link/page?option=WhatsYouWAnt&option2=... ). All options are listed on the API page. It's using promises to return answer so be sure to know what's you're doing.

API : Trello API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM