如何解决Google Apps脚本成功处理程序即使具有值服务器端,也从服务器功能接收到“空”
我正在使用GAS制作一个小型网络应用程序,以从Google电子表格中搜索数据。在我的前端,我有一个表格来进行搜索并显示数据。 当我单击此表单的搜索按钮时,将触发以下脚本:
document.getElementById("searchForm").addEventListener("click",searchSheet);
function searchSheet() {
google.script.run.withSuccessHandler(generateTable).getFullData();
}
Code.gs文件中的函数getFullData()检索我要在电子表格中使用的数据,并将其转换为对象数组。
function getFullData() {
const rawData = ws.getRange(2,2,ws.getLastRow()-1,ws.getLastColumn()-1).getValues();
const headers = ["region","country","location","clientType","clientName","projectTitle","status","startDate","endDate","workType","contact","fundingOrigin","partners","currency","projectValue","staffProvided","internalStaff","gdLink","sampleSize","blurb","themes","finalReport","fieldworkBudget","projectCode"];
const data = rawData.map((r,i) => {
let obj = {};
obj.id = i;
r.forEach((e,j) => obj[headers[j]] = e);
return obj
});
console.log(data);
return data;
}
此后,成功处理程序将触发函数generateTable
function generateTable(rawData) {
console.log(rawData);
//... rest of the function to search the array and create a nice table to display the data.
但是console.log(rawData);返回“ null”,当我检查日志服务器端时,我有想要的对象数组。 我已经在另一个项目上使用了类似的东西,所以我有点困惑为什么成功处理程序接收到空值。
谢谢您的反馈。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。