我们已经在几个项目中使用桌面作为从Google表格访问少量数据的简单方法。
以下是桌面.js Github ReadMe中的示例代码:
function init() {
Tabletop.init( { key: 'https://docs.google.com/spreadsheets/d/0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE/pubhtml',
callback: function(data, tabletop) {
console.log(data)
},
simpleSheet: true } )
}
window.addEventListener('DOMContentLoaded', init)
这是我的示例数据源:https://docs.google.com/spreadsheets/d/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/pubhtml
但是当我尝试执行此测试代码时:https://jsfiddle.net/BaronGrivet/oqnx2sjc/
<div id="data">
<strong>Data should appear here: </strong>
</div>
function init() {
Tabletop.init( {
key: 'https://docs.google.com/spreadsheets/d/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/pubhtml',
callback: function(data, tabletop) {
console.log(data)
document.getElementById('data').innerHTML += data
},
simpleSheet: true } )
}
init()
控制台中出现以下错误:
无法加载资源:服务器以状态 500 () 响应 https://spreadsheets.google.com/feeds/worksheets/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/public/basic?alt=json
加载 https://spreadsheets.google.com/feeds/worksheets/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/public/basic?alt=json 会显示"内部错误">
我意识到这意味着谷歌方面存在错误 - 但我不知道这是一个将要修复的错误,还是需要更改桌面的服务永久更改,或者已经停止了访问 JSON 的选项完全。
有没有人遇到过这个问题并找到了解决方案?
最好关注Google的问题跟踪 https://issuetracker.google.com/issues/131613284