【发布时间】:2021-07-02 09:01:07
【问题描述】:
我正在编写代码来列出在 Google Cloud Compute Engine 中创建的虚拟机。我正在使用 NodeJS 客户端库“@google-cloud/compute”Link to Client Library,然后我使用 compute.getVMs 方法来列出实例,并且我必须将 pageToken 作为 getVMs 方法的选项传递。我无法弄清楚如何将它作为代码中的选项传递并实现它。有人可以帮忙吗?
Link to compute.getVMs method and documentation
列出虚拟机实例的代码
'use strict';
async function main() {
const Compute = require('@google-cloud/compute');
const compute = new Compute();
async function listVMs() {
const vms = await compute.getVMs({
maxResults: 10,
});
console.log(`VMs Present are `, vms);
}
listVMs();
}
【问题讨论】:
标签: node.js google-cloud-platform pagination google-compute-engine