Google云端硬盘Node.Js TypeError:无法读取未定义driveResponse.id的属性“ id”

时间:2018-11-01 05:24:23

标签: javascript node.js google-api google-drive-api

我正在尝试从复制的Google云端硬盘文件中检索ID。每当我尝试检索driveResponse.id时,它总是以未定义的形式返回。这是重要的代码:

let request = {
        name: title,
      };
    var template = '1234567890987654321';
    var presentationId;
    return new Promise((resolve, reject) => {
      drive.files.copy({
        fileId: template,
        resource: request,
      }, (err, driveResponse) => {
          if (err){
              console.log("There was an error: " + err);
          }else{
            console.log('Created presentation with title: ' + title);
    //error happens here
            let presentationCopyId = driveResponse.id;
            console.log(presentationCopyId);
            resolve(presentationCopyId);

            r2.question("Presentation Id: ", function(presentationIdIn){
                presentationId = presentationIdIn;
                console.log("Please wait");
                r2.close();

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

0 个答案:

没有答案