node.js - 无法让 node-google-spreadsheet 在 Corvid Wix 中工作
问题描述
我正在尝试使用该node-google-spreadsheet
软件包(平台 Wix 和 Corvid),因此:
import { GoogleSpreadsheet } from 'google-spreadsheet';
function handleSpreadsheet(request) {
let doc = new GoogleSpreadsheet(<spreadsheet ID>);
doc.useServiceAccountAuth(<credentials>)
.then(() => {
doc.loadInfo();
})
.then(() => {
// Logging Point
var sheet = doc.sheetsByTitle['May 1'];
});
到 Logging Point 为止,一切似乎都运行正常。如果我在那里执行“console.log(doc)”,则表明 doc 具有一个_rawSheets
属性,该属性包含我的电子表格的所有正确工作表(两打左右);每张纸都有正确的 ID 和标题等。也就是说,它肯定至少从 Google 表格中加载了那么多数据。
但是对 doc.sheetsByTitle 的引用(这是下一步,获取工作表对象)会引发错误,我不知道为什么。其他工作表访问函数,例如 sheetById,也会引发错误。这些在源代码中被定义为“get”属性,就好像 Corvid 的 JS 不理解“get”一样。
绝望中我试图直接接近这些物体,但我不明白的东西阻止了我。以下是 console.log 输出的一些示例,均取自上面的 Logging Point:
console.log(doc._rawSheets) ==> { 0: {...}, 106791250: {...}, ...}
console.log(doc._rawSheets["0"]) ==> null
console.log(doc._rawSheets[0]) ==> null
console.log(Object.keys(doc._rawSheets)) ==> Array(0)
console.log(doc.sheetsByTitle) ==> null
科维德的特性?用户PEBKAC?非常感谢您对尝试的事情提出建议。
作为记录,node-google-spreadsheet 包的文档在这里。
解决方案
推荐阅读
- jquery - jQuery获取动态创建的多个(> 300)单选按钮的值
- firebase - Firebase 动态链接 CORS - XMLHttpRequest
- prolog - 为什么这些规则有效?(在序言中查找列表中的最后一个元素)
- mysql - 如何从数据库中获取每 n 个数据
- python - python - 从字符串中替换切片
- python - Flask:在页面之间传递对象
- visual-studio-code - VS Code 更新将不起作用
- c++ - 父类使用子方法
- angular5 - Angular 多个 rest api 请求
- laravel - 未找到 Laravel 视图 - 清除每个缓存后