【发布时间】:2020-10-21 09:33:19
【问题描述】:
我正在开发一个卡片插件,在这张卡片里面我试图调用一个谷歌管理员 SDK API。
(GET https://www.googleapis.com/admin/directory/v1/groups/groupKey) groupKey 的值可以是组的电子邮件地址、组别名或我使用的唯一组 ID:
AdminDirectory.Groups.Get(groupId)
我可以通过文本输入插入一个 groupKey,因为测试它会记录到 console.log。 现在我的问题是,如何将值作为文本或其他内容返回卡?
function myFunction(e) {
// Input from user.
var textInput = e.formInput.text_input;
const groups = myGroupsM.GroupsM();
// Export log on input from user "This works fine to console log"
console.log(groups.Groups.get(textInput));
// I tried below as a test to display text on card. Gives a error!
// Is it because it returns wrapped information? like this -> {infoyouget: []}
// Or do you need to give a parameter that you want to display?
var testText = CardService.newTextParagraph()
.setText(groups.Groups.get(text));
var card = CardService.newCardBuilder();
var cardSection = CardService.newCardSection().setHeader('Test Header')
.addWidget(testText);
// Found a thread on stackoverflow but it was about a clickable image. They suggested to use
// brackets in the return as below.
return [card.addSection(cardSection).build()];
} ```
【问题讨论】: