GDrive响应未定义

时间:2018-11-13 06:42:01

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

我正在尝试使用Google Drive REST API v3从驱动器获取ID。它返回为undefined。这是我的代码:

            //GETS ID
            async.doWhilst(function (callback) {
                drive.files.list({
                    q: 'trashed = false',
                    fields: 'nextPageToken, files(id, name)',
                    spaces: 'drive',
                    pageToken: pageToken
                }, function (err, res) {
                    if (err) {
                        // Handle error
                        error(err);
                        callback(err)
                    } else {

                        console.log(res.files);
//THIS IS THE LINE THAT RETURNS undefined ^^^^
                        res.files.forEach(function(file) {
                            console.log('Found file: ', file.name, file.id);
                        });
                        pageToken = res.nextPageToken;
                        callback();
                    }
                });
                }, function () {
                    return !!pageToken;
                }, function (err) {
                    if (err) {
                        error(err);
                    } else {
                        // All pages fetched
                    }
            });

感谢您提供的所有帮助。

0 个答案:

没有答案