我如何获取 Trello 列表中顶部卡片的某些信息?

时间:2020-12-28 09:46:14

标签: javascript arrays discord.js trello

我希望在我的电路板上的其中一个 Trello 列表中获取前几张卡片的名称、标签和截止日期,并使用我的机器人通过 Discord 发送它。我将如何获取这些信息?

1 个答案:

答案 0 :(得分:0)

您必须使用那里的 API,并使用 fetch 库来发出请求。他们给出了一些如何像这样使用他们的 API 的例子:

// 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));

您有很多选项需要处理,就像 php 选项 (link/page?option=WhatsYouWAnt&option2=...)。 API 页面上列出了所有选项。它使用承诺来返回答案,所以一定要知道你在做什么。

APITrello API

相关问题