vsasv
vsasv

Reputation: 870

Google Drive API Requests in JavaScript?

I am trying to list all the folders in my Google Drive, via the Google Drive API.

I copied the code from the API guide as follows:

var request = gapi.client.drive.files.list({
     'pageSize': 10,
     'fields': "nextPageToken, files(id, name)",

 });

This code returns ALL the files in my directory. How would I change the code to only include folders?

Thanks

Upvotes: 1

Views: 92

Answers (1)

vsasv
vsasv

Reputation: 870

It would be done like so in JavaScript:

var request = gapi.client.drive.files.list({
     'pageSize': 100,
     'fields': "nextPageToken, files(id, name)",
     'q':"mimeType='application/vnd.google-apps.folder'"

});

Where, the additional line is 'q':"mimeType='application/vnd.google-apps.folder'"

Upvotes: 1

Related Questions