I am creating a Google Drive Api site to get the comments from a Google doc. Every time I make a request I get: Uncaught TypeError: Cannot read property 'comments' of undefined. Here is my code:
<Html>
<head>
<title>test</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<script src="https://apis.google.com/js/client.js"></script>
<script>
function auth() {
var config = {
'client_id': '<YOUR_CLIENT_ID>',
'scope': 'https://www.googleapis.com/auth/urlshortener'
};
gapi.auth.authorize(config, function () {
console.log('login complete');
console.log(gapi.auth.getToken());
});
retrieveComments();
}
function retrieveComments() {
printComment('<fileid>');
}
function printComment(fileId) {
var request = gapi.client.drive.comments.list({
'fileId': fileId
});
request.execute(function (resp) {
if (!resp.error) {
console.log('Modified Date: ' + resp.modifiedDate);
console.log('Content: ' + resp.content);
} else {
console.log('Error code: ' + resp.error.code);
console.log('Error message: ' + resp.error.message);
// More error information can be retrieved with resp.error.errors.
}
});
}
</script>
</head>
<body>
<button onclick="auth();">Authorize</button>
</body>
</Html>
Please help! I am about to pull hair out.