Javascript 如何使用nextPageToken从google api检索联系人列表。工作示例

Javascript 如何使用nextPageToken从google api检索联系人列表。工作示例,javascript,google-cloud-functions,google-contacts-api,Javascript,Google Cloud Functions,Google Contacts Api,我使用此代码在firebase函数中检索我的联系人列表 ()示例 如果有下一个GetOken,那么我找不到任何工作示例 编辑-此代码能够通过数组连接解决分页问题 我能够想出这个解决方案,尽管现在我面临着一个推到连接阵列的问题。。。它不起作用了 const listOptions = { resourceName: "people/me", pageSize: 200, personFields: ['addre...'] } async functi

我使用此代码在firebase函数中检索我的联系人列表 ()示例

如果有下一个GetOken,那么我找不到任何工作示例

编辑-此代码能够通过数组连接解决分页问题 我能够想出这个解决方案,尽管现在我面临着一个推到连接阵列的问题。。。它不起作用了

const listOptions = {
    resourceName: "people/me",
    pageSize: 200,
    personFields: ['addre...']
}

async function getConnectionsList(contacts, nextPageToken) {
    if (!nextPageToken) {
        return contacts.people.connections.list(listOptions)
    } else {
        listOptions.pageToken = nextPageToken
        return contacts.people.connections.list(listOptions)
    }
}


        let response = await getConnectionsList(contacts)
        let nextPage = response.data.nextPageToken
        let connections = response.data.connections

        while (nextPage) {
            nextPage = await getConnectionsList(contacts, nextPage)
            connections.push(nextPage.data.connections) // not working
            connections.concat(nextPage.data.connections) // also not working...  

            nextPage = nextPage.data.nextPageToken
            console.log('hasNextPage?', nextPage)
        }

        console.log('connections',connections)

        resolve(connections)

运行代码时是否看到任何错误消息?或者你只是在运行它之后没有看到任何变化?我已经重新启动了操作系统并且刚刚开始工作。。。我猜有一些会话打开,甚至关闭浏览器是不够的。。。我必须重新启动OSYeah,可能是你的浏览器缓存的东西。。。谁知道呢?很高兴听到你的问题解决了!运行代码时是否看到任何错误消息?或者你只是在运行它之后没有看到任何变化?我已经重新启动了操作系统并且刚刚开始工作。。。我猜有一些会话打开,甚至关闭浏览器是不够的。。。我必须重新启动OSYeah,可能是你的浏览器缓存的东西。。。谁知道呢?很高兴听到你的问题解决了!
const listOptions = {
    resourceName: "people/me",
    pageSize: 200,
    personFields: ['addre...']
}

async function getConnectionsList(contacts, nextPageToken) {
    if (!nextPageToken) {
        return contacts.people.connections.list(listOptions)
    } else {
        listOptions.pageToken = nextPageToken
        return contacts.people.connections.list(listOptions)
    }
}


        let response = await getConnectionsList(contacts)
        let nextPage = response.data.nextPageToken
        let connections = response.data.connections

        while (nextPage) {
            nextPage = await getConnectionsList(contacts, nextPage)
            connections.push(nextPage.data.connections) // not working
            connections.concat(nextPage.data.connections) // also not working...  

            nextPage = nextPage.data.nextPageToken
            console.log('hasNextPage?', nextPage)
        }

        console.log('connections',connections)

        resolve(connections)