Javascript Google Api,如何使用Q?

问题描述 投票:0回答:1

一直在使用谷歌api客户端的网站,我想从用户的驱动器帐户获取一个文件夹列表,并在gapi中的所有内容都正确设置,以提出请求。问题是我不理解q请求对象的文档。

根据我的理解,我应该使用drive/files/list端点,并传递选项来过滤掉所有非文件夹。

从我可以从文档中收集到的是我的请求看起来应该是这样的:

gapi.client.drive.files.list({
   q: 'mimeType=application/vnd.google-apps.folder',
   pageSize: 25,
   fields: 'nextPageToken, files(name, kind, parents)'
}).then(response => console.log(response))
.catch(err => console.error(err));

但我继续得到这个错误:

 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value",
    "locationType": "parameter",
    "location": "q"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

我试图将q定义为'mimeType="application/vnd.google-apps.folder"''mimeType=\'application/vnd.google-apps.folder\''

但我得到相同的error in q结果。有人可以告诉我如何使用q参数?我确信在google api中搜索非常重要。

javascript google-api-client
1个回答
0
投票

适当的方法:

事实证明我实际上没有尝试过双引号,这最终是答案。

gapi.client.drive.files.list({
    q: 'mimeType="applicaton/vnd.google-apps.folder"',
    pageSize: 25,
    fields: 'nextPageToken, files(name, kind, parents)',
}).then(res => console.log(res)).catch(err => console.error(err));
© www.soinside.com 2019 - 2024. All rights reserved.