Javascript Google Api,Q怎么用?
Javascript Google Api, How to use Q?
一直在使用 google 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.
中搜索非常重要
合适的方法:
原来我没有真正尝试过双引号版本,这最终是答案。
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));
一直在使用 google 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.
合适的方法:
原来我没有真正尝试过双引号版本,这最终是答案。
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));