[英]Cannot read property 'spreadsheets' of undefined - google spreadSheet
I have problem like as title.我有标题这样的问题。 I sign in oauth2 and google return error我登录 oauth2 和谷歌返回错误
"Cannot read property 'spreadsheets' of undefined". “无法读取未定义的属性‘电子表格’”。 I tried copy sample from google page and same error;我尝试从谷歌页面复制样本,但出现同样的错误;
function makeApiCall() {
var spreadsheetBody = {
// TODO: Add desired properties to the request body.
};
var request = gapi.client.sheets.spreadsheets.create({}, spreadsheetBody);
request.then(function(response) {
// TODO: Change code below to process the `response` object:
console.log(response.result);
}, function(reason) {
console.error('error: ' + reason.result.error.message);
});
}
function initClient() {
var SCOPE = 'https://www.googleapis.com/auth/spreadsheets';
gapi.client.init({
'apiKey': 'myke',
'clientId': 'myclientID',
'scope': SCOPE,
// 'discoveryDocs': ['https://sheets.googleapis.com/$discovery/rest?version=v4'],
}).then(function() {
gapi.auth2.getAuthInstance().signIn();
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSignInStatus);
updateSignInStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
});
}
function updateSignInStatus(isSignedIn) {
if (isSignedIn) {
makeApiCall();
}
}
gapi.load('client:auth2', initClient);
It's because you've commented out the "Discovery Docs" line.这是因为您已注释掉“Discovery Docs”行。 GAPI needs to know the discovery docs in order to load the correct API endpoints. GAPI 需要知道发现文档才能加载正确的 API 端点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.