【发布时间】:2017-11-08 11:25:32
【问题描述】:
如何在 powerup 中查询 trello API?这似乎是一个显而易见的问题,但我似乎找不到涵盖的内容。
到目前为止,我的简单加电看起来像这样:
var boardButtonCallback = function(t){
return t.popup({
title: 'Tools',
items: [
{
text: 'Hide Duplicates',
callback: function(t){
var cardQueryCb = function(result){
console.log(result);
}
var cardQ = 'https://trello.com/1/boards/[board_id]/cards/all';
fetch(cardQ).then(function(response) {
return response.json();
}).then(function(data) {
console.log(data);
});
return t.cards('id', 'name')
.then(cardQueryCb);
}
}
]
});
};
TrelloPowerUp.initialize({
'board-buttons': function(t, options){
return [{
text: 'Duplicates',
callback: boardButtonCallback
}];
}
});
调用 fetch 后的响应对象表示该调用未经授权。
我原以为从加电上下文中调用此代码将被视为已授权。当我登录到 trello 时,我可以将该地址放入我的浏览器并获得有效响应 - 为什么 javascript 调用也不会产生有效响应?
更重要的是,我怎样才能从该 URL 获得成功的响应?
【问题讨论】:
标签: javascript trello trello-powerup