首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读取未定义的属性‘spreadSheet’- google spreadSheet

无法读取未定义的属性‘spreadSheet’- google spreadSheet
EN

Stack Overflow用户
提问于 2018-12-06 00:11:28
回答 1查看 1.5K关注 0票数 1

我有像头衔这样的问题。我登录oauth2,谷歌返回错误

“无法读取未定义的属性'spreadsheets‘”。我尝试从google页面复制样本,但同样的错误;

代码语言:javascript
复制
   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);
EN

回答 1

Stack Overflow用户

发布于 2020-03-05 12:39:01

这是因为您注释掉了"Discovery Docs“行。GAPI需要知道发现文档,以便加载正确的API端点。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53636377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档