Node.JS Google Slides API TypeError: Невозможно прочитать свойства «презентации» неопределенных - PullRequest
0 голосов
/ 29 октября 2018

Я довольно новичок в Node.JS и API Google Slides. Я использовал быстрый запуск и изменил его, и получаю сообщение об ошибке:

(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]
        });
    }

Любая помощь будет принята с благодарностью, спасибо!

1 Ответ

0 голосов
/ 29 октября 2018

Изменить this.slidesService.presentations.create на slides.presentations.create

...