简体   繁体   English

Uncaught TypeError:无法读取未定义的属性“ calendar”-Google Calendar API

[英]Uncaught TypeError: Cannot read property 'calendar' of undefined - Google Calendar API

I'm playing around with OAuth2 and Calendar API using Javascript. 我正在使用Javascript处理OAuth2和Calendar API。 I'm using a following test function to see if the event is being added to the calendar (after authentication of the user by the API). 我正在使用以下测试功能来查看是否将事件添加到日历中(通过API对用户进行身份验证之后)。

function addTestEvent()
    {

        var event = {
            'summary': 'Google I/O 2015',
            'location': '800 Howard St., San Francisco, CA 94103',
            'description': 'A chance to hear more about Google\'s developer products.',
            'start': {
                'dateTime': '2015-05-28T09:00:00-07:00',
                'timeZone': 'America/Los_Angeles'
            },
            'end': {
                'dateTime': '2015-05-28T17:00:00-07:00',
                'timeZone': 'America/Los_Angeles'
            }
        };

        var request = gapi.client.calendar.events.insert({
            'calendarId': 'primary',
            'resource': event
        });

        request.execute(function(event) {
            alert(event.htmlLink);
            alert("called?");
        });
    }

I'm using the example from the documentation. 我正在使用文档中的示例。

In the console, I get the message saying calendar is undefined (referring to the var request = ... line) 在控制台中,我收到消息说日历未定义(指的是var request = ...行)

Uncaught TypeError: Cannot read property 'calendar' of undefined

I have included the 我已经包括了

<script src="https://apis.google.com/js/api.js"></script>

in my page. 在我的页面中。 What am I doing wrong here? 我在这里做错了什么?

Also, is there a tutorial or a good example that would help me understand the whole process, because the docs are kinda thin in my opinion? 另外,由于我觉得这些文档太薄了,是否有一个教程或一个很好的示例可以帮助我理解整个过程?

You should provide more of your code because if it's saying calendar of undefined then I'm assuming the client for gapi.client wasn't instantiated correctly. 您应该提供更多的代码,因为如果说未定义的calendar ,那么我假设gapi.clientclient未正确实例化。

Likely need to make sure all the authing is done before you try to access the client as the client needs to verify the credentials. 在尝试访问客户端之前,可能需要确保所有身份验证都已完成,因为客户端需要验证凭据。

And this documentation example should be a fairly straight copy paste and modify to get a working example: https://developers.google.com/calendar/quickstart/js 这个文档示例应该是相当简单的复制粘贴,并进行修改以得到一个有效的示例: https : //developers.google.com/calendar/quickstart/js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React TypeError 中的完整日历:无法读取未定义的属性“日历” - Full Calendar in React TypeError: Cannot read property 'calendar' of undefined 无法读取未定义的属性“事件”(Google 日历 API) - Cannot read property 'events' of undefined (Google calendar API) 未捕获的TypeError:无法读取未定义的属性“ URL”-Google Image API - Uncaught TypeError: Cannot read property 'url' of undefined - Google Image API 未捕获到的TypeError:无法读取Google Map API中未定义的属性“ PlacesService” - Uncaught TypeError: Cannot read property 'PlacesService' of undefined in google map api 未捕获的TypeError:无法读取undefined的属性&#39;row&#39; - google visualization api - Uncaught TypeError: Cannot read property 'row' of undefined - google visualisation api 未捕获的TypeError:无法读取未定义的属性“ 0”(Google Feed API) - Uncaught TypeError: Cannot read property '0' of undefined (Google Feed API) 未捕获的类型错误:无法使用 Google 图书 API 读取未定义的属性“1” - Uncaught TypeError: Cannot read property '1' of undefined using Google Books API tui-calendar.js:3512未捕获的TypeError:无法读取未定义的属性“ split” - tui-calendar.js:3512 Uncaught TypeError: Cannot read property 'split' of undefined 拖动事件的完整日历 -&gt; 未捕获的类型错误:无法读取未定义的属性“isWithinClipping” - Full calendar on drag events -> Uncaught TypeError: Cannot read property 'isWithinClipping' of undefined moment.js:423未捕获的TypeError:无法读取未定义的属性“ _calendar” - moment.js:423 Uncaught TypeError: Cannot read property '_calendar' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM