Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paging examples to continue on empty page #436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions advanced/drive.gs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ function listRootFolders() {
pageSize: 100,
pageToken: pageToken
});
pageToken = folders.nextPageToken;
if (!folders.files || folders.files.length === 0) {
console.log('All folders found.');
return;
continue;
}
for (let i = 0; i < folders.files.length; i++) {
const folder = folders.files[i];
console.log('%s (ID: %s)', folder.name, folder.id);
}
pageToken = folders.nextPageToken;
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
}
} while (pageToken);
console.log('All folders found.');
}
// [END drive_list_root_folders]

Expand Down Expand Up @@ -109,22 +109,22 @@ function listRevisions(fileId) {
revisions = Drive.Revisions.list(
fileId,
{'fields': 'revisions(modifiedTime,size),nextPageToken'});
pageToken = revisions.nextPageToken;
if (!revisions.revisions || revisions.revisions.length === 0) {
console.log('All revisions found.');
return;
continue;
}
for (let i = 0; i < revisions.revisions.length; i++) {
const revision = revisions.revisions[i];
const date = new Date(revision.modifiedTime);
console.log('Date: %s, File size (bytes): %s', date.toLocaleString(),
revision.size);
}
pageToken = revisions.nextPageToken;
} catch (err) {
// TODO (developer) - Handle exception
console.log('Failed with error %s', err.message);
}
} while (pageToken);
console.log('All revisions found.');
}

// [END drive_list_revisions]
Loading