gpt4 book ai didi

javascript - Node.JS Google Slides API 类型错误 : Cannot read property 'presentations' of undefined

转载 作者:行者123 更新时间:2023-12-03 00:51:06 26 4
gpt4 key购买 nike

我对 Node.JS 和 Google Slides API 相当陌生。我一直在使用快速入门并对其进行修改,但遇到了错误:

(node:22396) UnhandledPromiseRejectionWarning: TypeError: Cannot read 
property 'presentations' of undefined

这是我的代码,快速入门中的授权功能未受影响,因此不包括在内。

const fs = require('fs');
const readline = require('readline');
const {google} = require('googleapis');
const promise = require('promise');
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/presentations.readonly'];
const TOKEN_PATH = 'token.json';

var auth = '000000000000-ithinkthissupposedtobesecret.apps.googleusercontent.com';
var title = "Cheese";

// Load client secrets from a local file.
fs.readFile('credentials.json', (err, content) => {
if (err) return console.log('Error loading client secret file:', err);
// Authorize a client with credentials, then call the Google Slides API.
authorize(JSON.parse(content), createPresentation);
});
/**
Authorization from quickstart goes here (https://developers.google.com/slides/quickstart/nodejs)
*/
function createPresentation(title, auth) {
const slides = google.slides({version: 'v1', auth});
return new Promise((resolve, reject) => {
// [START slides_create_presentation]
this.slidesService.presentations.create({
title,
}, (err, presentation) => {
if (err) return console.log(err);
console.log(`Created presentation with ID: ${presentation.presentationId}`);
// [START_EXCLUDE silent]
resolve(presentation);
// [END_EXCLUDE]
});
// [END slides_create_presentation]
});
}

任何帮助将不胜感激,谢谢!

最佳答案

this.slidesService.presentations.create 更改为 slides.presentations.create

关于javascript - Node.JS Google Slides API 类型错误 : Cannot read property 'presentations' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53037755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com