javascript - 从 google drive api 获取所有驱动器并将其与 graphQl 一起使用
问题描述
我一辈子都想不出如何解决这个问题……我有一个 util.js 来设置谷歌驱动器常量。它需要一个回调。这是我使用的代码。
我让它与rest api一起工作,因为我只是在这个里面返回它......但是现在我需要在它作为GraphQL中的一个字段完成时返回它......我知道这段代码看起来很乱,但我很乐意帮助,并尝试了解如何修复它。第一行“驱动器”是graphql。
drives: {
type: GraphQLList(GraphQLString),
resolve: async () =>
drive(async (drive) => {
let drives = [];
function getDrives(nextPageToken) {
drive.drives
.list({
pageSize: 99,
useDomainAdminAccess: true,
// eslint-disable-next-line quotes
q: "name contains ''",
pageToken: nextPageToken,
supportsAllDrives: true,
fields: 'nextPageToken,drives',
})
.then((result) => {
drives.push(...result.data.drives);
// console.log('PAGE TOKEN: ' + result.data.nextPageToken);
if (result.data.nextPageToken) {
console.log('INSIDE PROMISE');
// return drives;
getDrives(result.data.nextPageToken);
}
})
.then((result) => {
// console.log(result.length);
if (result) {
console.log(drives.length);
return drives;
}
})
.then(() => {
console.log('Ferdig');
})
.catch();
}
return drives;
}),
},
}),
解决方案
推荐阅读
- sql-server - SQL找出哪个登录名/用户修改了表结构
- substrate - 如何在 Substrate 中安装四个节点的网络
- angular - Angular 组件不会对属性更改做出反应
- ios - 离子(Appflow):请注册自定义 URL 方案 - 方案存在于 plist 文件中
- haskell - Control.Lens 中的 Market 名称背后的原因是什么?
- python - 改组数据框中的多列
- function - Sharepoint 如何更改新文档的功能
- javascript - Jest 模拟不适用于 react-native 输入
- javascript - Vue JS:同时获取输入数组的唯一ID和值
- uwp - 如何使用 UWP Backbround Task 从本地存储(比如 "C:\\" )读取文件?